table.js 837 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 桌台表
  5. const table = {
  6. name: { type: String, required: false, zh: '桌台类型' }, //
  7. remark: { type: String, required: false, zh: '备注' }, //
  8. type: { type: String, required: false, zh: '备注' }, //
  9. is_use: { type: String, required: false, zh: '是否启用', default: '0' }, //
  10. };
  11. const schema = new Schema(table, {
  12. toJSON: { getters: true, virtuals: true },
  13. });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.index({ name: 1 });
  17. schema.index({ remark: 1 });
  18. schema.index({ type: 1 });
  19. schema.index({ is_use: 1 });
  20. schema.plugin(metaPlugin);
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('Table', schema, 'table');
  24. };