test.js 829 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 测试接口
  5. const test = {
  6. name: { type: String, required: false, zh: '名称' }, //
  7. brief: { type: String, required: false, zh: '简介' }, //
  8. path: { type: String, required: false, zh: '视频流' }, //
  9. is_use: { type: String, required: false, zh: '是否启用', default: '0' }, //
  10. };
  11. const schema = new Schema(test, { toJSON: { getters: true, virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.index({ 'meta.createdAt': 1 });
  14. schema.index({ name: 1 });
  15. schema.index({ brief: 1 });
  16. schema.index({ path: 1 });
  17. schema.index({ is_use: 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('Test', schema, 'test');
  22. };