I am using waterline and waterlinhe-orientdb. I have user and order vertex classes and bought edge class User ---Bought-->Orders I am trying to apply Where criteria on populate. But is not working on populate. Here is my code
var CREDIT_CARD = 1;
User.find({id:userid}).populate('boughts',{where:{payment_method:CREDIT_CARD}})
Schema
USER = {
identity: 'user',
connection: 'myLocalOrient',
attributes:{
status: { type:"integer", columnName:"status"},
fname: { type:'string'},
lname: { type:'string'},
boughts: {collection: 'orders',through: 'boughts',via: 'user',dominant: true}
};
Bought = {
identity:'boughts',
connection: 'myLocalOrient',
attributes:{
status:{type:'integer', columnName:'status'},
buyers:{
columnName: 'out',
type: 'string',
foreignKey: true,
references: 'users',
on: 'id',
onKey: 'id',
via: 'orders'
},
orders:{
columnName: 'in',
type: 'string',
foreignKey: true,
references: 'orders',
on: 'id',
onKey: 'id',
via: 'buyer'
}
}
};
Order = {
identity:'orders',
connection: 'myLocalOrient',
attributes:{
status:{type:'integer',columnName:'status'},
payment_method:{type:'integer', columnName:'payment_method'},
boughts:{collection:'users', through:'boughts',via:'orders'}
}
};
9me, from your model definition I can see you are using many-to-many through associations which are not yet officially supported by Waterline. This means that some functionality may not be fully operational and that some errors may occur. For more details read When Many-to-Many Through Associations release? #705.
Your query is also not correct:
The criteria in
.populate()
does not take the keywhere
.Here's an example from the documentation:
So, in your case you should use: