Implement Association in MongoDB -
i need implement association between objects in mongodb allow retrieval queries level. suppose have model account->application->device->users. suppose want query on user collection using account reference, or level of hierarchy want query on users.
as have no support joins cannot keep separate association collection, if keep association collection have series of queries, , output association collection can huge array of objects , left 2 options use
iterative query each object array
use $in operator
both disastrous use if array big.
i have figured out approach keep tree of ancestors follow document.
{ _id: objectid(""), name:"", timestamp:isodate(" "), ... ancestors :[{_id:objectid(""),..},{_id:objectid(""),..},{_id:objectid(""),..}] }
suppose users document ancestors deviceid,applicationid,accountid. not sure how useful be. 1 thing sure above model if new level in added updating going pain.
the main thing why want implement model implement loosely coupled model.
thanks advance!!!
Comments
Post a Comment