0

Hi is it possible to create a chained hasmany relationship like this:

Customer has Sensors and Sensors has Meterings

Customer -> Sensors -> Metering

So that i can access Meterings over the Customer Model.

For Example: http://localhost:3000/api/Customers/1/Sensors/2/Meterings

Is this possible in anyway with loopback?

cebor
  • 6,546
  • 4
  • 24
  • 31
  • You can chain model relations with include filter. http://docs.strongloop.com/display/public/LB/Include+filter – A.Z. Jun 11 '15 at 18:41

1 Answers1

1

You can create hasAndBelongsToMany and hasManyThrough relations to achieve this. It's likely that your API call would end up looking something like:

/Customers/1?filter={"include":["meterings"],"where":{"sensorId":2}}

conradj
  • 2,481
  • 2
  • 24
  • 30