mardi 14 avril 2015

Retrieve specific values from a collection in sailsjs model

Merchant.js



module.exports = {

attributes: {
name:{
type:'string',
required:true
},
drinks:{
collection:'Drinks',
via:'merchant'
}
}
};


Drinks.js



module.exports = {

attributes: {
name:{
type:'string',
required:true
},
category:{
model:'Category'
},
merchant:{
model:'Merchant'
}
}

};


Category.js



module.exports = {

attributes: {
name:{
type:'string',
required:true,
unique: true
}
}
};


I want to retrieve the merchant with the drinks associated with the given input category. Can someone help me in the find query.


Thanks


Aucun commentaire:

Enregistrer un commentaire