我想創建模式,其中body
可以根據進入的事件有它不同的密鑰。所以當我嘗試呈現數據時,只需將_id
發送給客戶端event
不是結果的一部分。我用這種方法實施了錯誤的模式嗎?如何在有動態值時使用貓鼬模式?
event.model.js
var mongoose = require('bluebird').promisifyAll(require('mongoose'));
var bmpEventSchema = new mongoose.Schema({
event: {
type: String,
body : {}
}
});
export default mongoose.model('BmpEvent', bmpEventSchema);
JsonDocument
{
"_id" : ObjectId("596f672f4c387baa25db5ec6"),
"event" : {
"type" : "json",
"body" : {
"evntType" : "Smtduki",
"tkt" : "75522655",
"cat" : "RNT",
"esc_lvl" : "4",
"asset" : "DNEC843027 ATI",
"esc_tm" : "2017-05-26 09:18:00",
"tos" : "T3APLS",
"mcn" : "SL6516",
"cusTkt" : "",
"tktSrc" : "BMP",
"tier1" : "STLMOETS"
}
}
}
這真的不是我清楚你問這裏。 –
不需要提供貓鼬方法。 – Lazyexpert