collects.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 我的收藏
  5. const collects = {
  6. user_id: { type: String, required: false, zh: '用户id' }, //
  7. user_name: { type: String, required: false, zh: '用户名称' }, //
  8. video_id: { type: String, required: false, zh: '视频id' }, //
  9. title: { type: String, required: false, zh: '视频名称' }, //
  10. img_url: { type: Array, required: false, zh: '图片' }, //
  11. view_num: { type: String, required: false, zh: '观看次数' }, //
  12. time_num: { type: String, required: false, zh: '时长' }, //
  13. follow_time: { type: String, required: false, zh: '关注时间' }, //
  14. };
  15. const schema = new Schema(collects, { toJSON: { getters: true, virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ 'meta.createdAt': 1 });
  18. schema.index({ user_id: 1 });
  19. schema.index({ user_name: 1 });
  20. schema.index({ video_id: 1 });
  21. schema.index({ title: 1 });
  22. schema.index({ view_num: 1 });
  23. schema.index({ time_num: 1 });
  24. schema.index({ follow_time: 1 });
  25. schema.plugin(metaPlugin);
  26. module.exports = app => {
  27. const { mongoose } = app;
  28. return mongoose.model('Collects', schema, 'collects');
  29. };