findById({}) in LoopBack

2.1k views Asked by At

If i want to modify this find with findById({}).

How to modify in loopback +angular 2 SDk?

.find({offset: 0,   
           limit: 100         
         })
   .subscribe(function(response: any)
      {           
       });
1

There are 1 answers

0
itssajan On BEST ANSWER

If you are using findById({}) then there is no need for further filters like offset and limit, as findById({}) return one single object based on the id

    User.findById({
      id: your_id,
      filter:{
        include:{
          relation: 'roles'
        }
      }
    })

This is an example of retrieving a User object with the roles relation.

Note: The syntax is based on Angular 1, haven't tried on Angular 2