Search code examples
angularsdkloopback

findById({}) in LoopBack


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)
      {           
       });

Solution

  • 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