category.js 512 B

1234567891011121314151617
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const SchemaDefine = {
  4. code: { type: String, required: true, maxLength: 64 },
  5. name: { type: String, required: true, maxLength: 128 },
  6. key: { type: String, required: true, maxLength: 64 },
  7. order: Number,
  8. };
  9. const schema = new Schema(SchemaDefine);
  10. schema.index({ code: 1 }, { unique: true });
  11. schema.index({ key: 1 });
  12. module.exports = app => {
  13. const { mongoose } = app;
  14. return mongoose.model('CodeCategory', schema, 'naf_code_category');
  15. };