Last active
December 28, 2015 21:08
-
-
Save naholyr/7562037 to your computer and use it in GitHub Desktop.
Mongoose fixtures proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// 1 document in this collection | |
"Collection": [ | |
{"fieldName": "value", "dbRefField": {"$ref": "OtherCollection", "$idx": 0}} | |
// dbRefField == OtherCollection[0] once made available | |
], | |
// 2 documents in this collection | |
"OtherCollection": [ | |
{"otherField": "value1"}, | |
{"otherField": "value2"} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async.auto({ | |
"Collection:0": ['OtherCollection:0', function (cb, o) { (new Collection({fieldName: "value", dbRefField: o['OtherCollection:0']})).save(cb) }], | |
"OtherCollection:0": function (cb) { (new OtherCollection({otherField: "value1"})).save(cb) }, | |
"OtherCollection:1": function (cb) { (new OtherCollection({otherField: "value2"})).save(cb) } | |
}, function (err, res) { | |
/* … */ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment