type.js 640 B

1234567891011121314151617181920
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. const { ObjectId } = require('mongoose').Types;
  5. // 商品类型
  6. const type = {
  7. code: { type: String }, // 类别code
  8. name: { type: String }, // 名称
  9. remark: { type: String },
  10. };
  11. const schema = new Schema(type, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.index({ code: 1 });
  14. schema.index({ name: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model("Type", schema, "type");
  20. };