mongodb - Meteor: Relating Items -


i'm using meteor , mongodb, suggested documentation. coming relational database background, want understand strategies modeling data in nosql stores.

the scenario have users, , each user has 1 vin. pretty standard , possible 1 collection. if want find highest vin display anonymous information purchased car, construct find like:

users.find({}, sort: {vin_number: -1})

or there better way model it? if given user has more 1 vin? in relational world, that's "has many" relationship. if embed array of vins in user document, how extract highest number.

as can see, wrestling fundamental shift modeling things tables embedded documents.

any appreciated, , (although know it's not way) i'd love pointers places gentle migration relational modeling patterns schema-less ones.

you use transform highest vin list of vins:

users.find({}, {sort: {vin_number: -1}, transform: function(doc) {     doc.vin_number = _.max(doc.vin_number_array);     return doc; }}) 

i've never tried this, i'm bit unsure of whether transform or sort comes first. if had array of vin numbers in vin_number_array in document, vin_number end highest of using underscore's max function.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -