私のスキーマが次のようになっている場合:
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 オブジェクトからのデータを使用して次のテーブルが作成されます。
- 構成
- ウェブサービス