'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 位置表 const LocationSchema = { name: { type: String, required: true, maxLength: 500 }, // 名称 ibeacon: { type: String, required: true, maxLength: 500 }, // 蓝牙设备号 }; const schema = new Schema(LocationSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Location', schema, 'location'); };