node.js - Sails 0.10 & Many-to-Many association - Get all associated data, not the first only -


i have 2 models many-to-many association. code associate these 2 models working (it create new collection item_languages__language_items corresponding documents inside). have trouble associated data (languages) of specific item. i'm using mongodb.

// item.js module.exports = {     schema: true,     autopk: false,     attributes: {         uuid: {             type: 'string',             primarykey: true,             unique: true,             required: true,             uuidv4: true         },         languages: {             collection: 'language',             via: 'items',             dominant: true         }     } }  // language.js module.exports = {     schema: true,     autopk: false,     attributes: {         code: {             type: 'string',             primarykey: true,             required: true,             minlength: 2,             maxlength: 2,             unique: true         },         items: {             collection: 'item',             via: 'languages'         }     } } 

data stored in item_languages__language_items collection:

/* 0 */ {     "language_items" : "es",     "item_languages" : "69e4f3a3-1247-4a06-ae2d-9df27ac9495b",     "_id" : objectid("5330bcebf8e0b61509c771d5") }  /* 1 */ {     "language_items" : "fr",     "item_languages" : "69e4f3a3-1247-4a06-ae2d-9df27ac9495b",     "_id" : objectid("5330bd26f8e0b61509c771d6") }  /* 2 */ {     "language_items" : "en",     "item_languages" : "69e4f3a3-1247-4a06-ae2d-9df27ac9495b",     "_id" : objectid("5330bedcc076355b09da3ccd") } 

now in itemcontroller.js, want specific item associated languages:

item     .findone({uuid: '69e4f3a3-1247-4a06-ae2d-9df27ac9495b'})     .populate('languages')     .exec(function (e, r) {         console.log(r.tojson());     }); 

but here item 1 associated language, when expected 3 associated languages.

this appears bug in current beta implementation of sails-mongo keeps populate working custom-defined keys. please post sails-mongo issues forum! in meantime solution appears to use default mongodb primary keys.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -