document.js 663 B

1234567891011121314151617181920
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 积分归档
  5. const DocumentSchema = {
  6. create_time: { type: String, required: false, zh: '归档时间' }, //
  7. record: { type: Array, required: false, zh: '记录' }, //
  8. };
  9. const schema = new Schema(DocumentSchema, { toJSON: { getters: true, virtuals: true } });
  10. schema.index({ id: 1 });
  11. schema.index({ 'meta.createdAt': 1 });
  12. schema.index({ create_time: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Document', schema, 'document');
  17. };