/** * 日志数据结构 * * @author CaiAoLin * @date 2017/7/27 * @version */ import mongoose from "mongoose"; let Schema = mongoose.Schema; let collectionName = 'log'; let messageSchema = new Schema({ ip: String, ip_info: String, browser: String, os: String }, {_id: false}); let modelSchema = { // 日志类型 type: { type: Number }, // 日志内容 message: messageSchema, // 关联用户id user_id: { type: String }, // 创建时间 create_time: Number }; mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));