loopback include multiple relations code example
Example 1: loopback include multiple relations
Post.find({
include: {
relation: 'owner',
scope: {
fields: ['username', 'email'],
include: {
relation: 'orders',
scope: {
where: {orderId: 5}
}
}
}
}
}, function() { });
Example 2: loopback relation include to json
Post.find({include: {owner: [{posts: 'images'} , 'orders']}}, function(err, posts) {
posts.forEach(function(post) {
var p = post.toJSON();
console.log(p.owner.posts, p.owner.orders);
});
});
Example 3: loopback relations include inside include
<ion-datetime displayFormat="HH:mm" [(ngModel)]="myDate" minuteValues="0,30">
Example 4: loopback 3 includes many
User.find({include: ['posts', 'orders']}, function() { });
Example 5: loopback relations include inside include
Post.find({include: {owner: [{posts: 'images'} , 'orders']}},
function() { });
Example 6: loopback include relation
in url:
/customers?filter[include]=reviews
in code:
User.find({include: 'reviews'}, function() { });