0
所以我想弄清楚如何在命令列表中保存多個命令,但我試過的所有東西都沒有工作。這是我有它成立至今,但是當它保存,它的如何獲得這個嵌套的模式在Mongoose中工作?
"command_list" : [ { "action" : "goto,goto", "target" : "http://www.google.com,http://www.cnn.com" } ]
的格式保存時,我真的希望是這樣
"command_list" : [ "command" : { "action" : "goto", "target" : "http://www.google.com" },
"command" : { "action" : "goto", "target" : "http://www.cnn.com" } ]
在有多個命令。到目前爲止,我app.js的存儲數據這樣
var configSample = new Configurations({
command_list_size: request.body.command_list_size,
command_list: [ {action: request.body.action, target: request.body.target}]
});
和模型看起來像這樣
var mongoose = require("mongoose");
var command = mongoose.Schema({
action: String,
target: String
});
var configSchema = mongoose.Schema({
command_list_size: Number,
command_list: [command]
});
module.exports = mongoose.model('Configurations', configSchema);
那麼,如何獲取築巢行動去?謝謝!