# 使用说明

---

## 多租户模式

### 1.model配置中

>```const schema = new Schema(user, { 'multi-tenancy': true, toJSON: { virtuals: true } });```

---

## 有关populate使用说明

如果使用框架中的populate进行关联查询,ref部分将不再是单纯的表名(模型名,model),而是需要带路径的表名
>e.g.:目录结构为
model
|`__`user
$~~~~~~$|`__`user.js

在某model的字段关联user时,需要写成: `key: {..., ref: 'User.User', ...}`
若要获取该关联的属性, 添加 `getProp` 属性 : `key: {..., ref: 'User.User', getProp: ['${prop}','${key}.${prop}'] ...}`

在config设置中有 `config.queryRefs` 默认不启用 ref关联查询.需要设置该变量为`true`才可自动关联

ps:自己写的话,随便

---

## 中间件说明

### password

针对以 非login结尾 的 POST 方法的路由,且 request.headers 中 没有 passwordNoDeal 或 passwordNoDeal 为 false 的请求中. 将 body中的password字段 修改为 {secret:password}的形式

---

## npm 发布相关

## `npm version patch` 更新版本号

## `npm publish` 发布

## `npm unpublish <包名(@版本)>` 删除指定包的依赖(指定版本)

## `npm i naf-framework-mongoose-free@latest` 项目中升级最新版本
