그래서 여러 명령을 명령 목록에 저장하는 방법을 알아 내려고했지만 시도한 모든 것이 제대로 작동하지 않았습니다. 이것은 내가 지금까지 설정할 수 있지만 저장할 때 정말 여러 명령이 있습니다Mongoose에서이 중첩 스키마를 어떻게 작동 시키나요?
"command_list" : [ "command" : { "action" : "goto", "target" : "http://www.google.com" },
"command" : { "action" : "goto", "target" : "http://www.cnn.com" } ]
같은 것을 할 때, 그것은
"command_list" : [ { "action" : "goto,goto", "target" : "http://www.google.com,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);
처럼 보인다? 감사!