如果我的架构如下:
var Configuration = describe('Configuration', function () {
property('name', String);
set('restPath', pathTo.configurations);
});
var Webservice = describe('Webservice', function () {
property('wsid', String);
property('url', String);
});
Configuration.hasMany(Webservice, { as: 'webservices', foreignKey: 'cid'});
这反映了这样的数据:
var configurationJson = {
"name": "SafeHouseConfiguration2",
"webServices": [
{"wsid": "mainSectionWs", "url":"/apiAccess/getMainSection" },
{"wsid": "servicesSectionWs", "url":"/apiAccess/getServiceSection" }
]
};
我不应该能够使用以下内容播种 mongoDB:
var configSeed = configurationJson;
Configuration.create(configSeed, function (err, configuration) {
)};
这将使用来自 json 对象的数据创建以下表:
- 配置
- 网络服务