12345678910111213141516171819202122232425 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 测试接口
- const test = {
- name: { type: String, required: false, zh: '名称' }, //
- brief: { type: String, required: false, zh: '简介' }, //
- path: { type: String, required: false, zh: '视频流' }, //
- is_use: { type: String, required: false, zh: '是否启用', default: '0' }, //
- };
- const schema = new Schema(test, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ name: 1 });
- schema.index({ brief: 1 });
- schema.index({ path: 1 });
- schema.index({ is_use: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Test', schema, 'test');
- };
|