'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 角色表 const role = { name: { type: String, zh: '名称' }, code: { type: String, zh: '编码' }, remark: { type: String }, }; const schema = new Schema(role, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Role', schema, 'role'); };