log.js 684 B

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