loopback relation include to json code example

Example 1: loopback relation include to json

Post.find({include: {owner: [{posts: 'images'} , 'orders']}}, function(err, posts) {
 posts.forEach(function(post) {
   // post.owner points to the relation method instead of the owner instance
   var p = post.toJSON();
   console.log(p.owner.posts, p.owner.orders);
 });
 //... 
});

Example 2: loopback relations include inside include

<ion-datetime displayFormat="HH:mm" [(ngModel)]="myDate" minuteValues="0,30">

Example 3: loopback relations include inside include

// Return all post owners (users), and all posts and orders of
// each owner. The posts also include images.
Post.find({include: {owner: [{posts: 'images'} , 'orders']}}, 
          function() { /* ... */ });

Example 4: loopback 3 includes many

User.find({include: ['posts', 'orders']}, function() { /* ... */ });

Tags:

Html Example