用途:为 Nuxt 应用提供基于仓库模式的数据访问层,把 API 调用与模型水合集中管理。主要能力:继承 BaseRepository 定义资源路径、开启水合并指定 ModelHydrator;仓库支持 list、get、create、update、delete 等 CRUD 操作,返回水合后的模型;可添加自定义方法(如按作者查询),支持查询参数如 include 与 filter。使用方式:在 app/repositories 下创建仓库类,通过 app.config.ts 的 repositories 字段注册,再用 useRepository('posts') 获取类型化实例并调用方法。限制:资料未提供安装命令、版本要求、错误处理与鉴权细节。
nuxt-repositories
编程与开发
更新于 10-16 06:23