log.js 650 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * 日志数据结构
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/7/27
  6. * @version
  7. */
  8. const mongoose = require('mongoose');
  9. let Schema = mongoose.Schema;
  10. let collectionName = 'log';
  11. let messageSchema = new Schema({
  12. ip: String,
  13. ip_info: String,
  14. browser: String,
  15. os: String
  16. }, {_id: false});
  17. let modelSchema = {
  18. // 日志类型
  19. type: {
  20. type: Number
  21. },
  22. // 日志内容
  23. message: messageSchema,
  24. // 关联用户id
  25. user_id: {
  26. type: String
  27. },
  28. // 创建时间
  29. create_time: Number
  30. };
  31. mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));