0

I am trying to reference the orders object with nested ids (using the amazing ng-admin):
{"user": "id": 1, "orders": [ {"order_id": 100}, {"order_id": 101} ]}

This is the view definition:
user.showView().fields([ nga.field('orders.id', 'reference_many') .targetEntity(order) .targetField('id') ]);

The code above returns the following error:

(state change error: e.targetField(...).name is not a function)

Can someone can help?

nak
  • 690
  • 6
  • 15

1 Answers1

0

As explained in the doc, reference_many is relevant when you have an array of foreign keys. In your example, you don't have an array of (scalar) foreign keys, but an array of objects. If you want to use reference_many, you have to use a Restangular Interceptor to make the entity look like what ng-admin expects.

François Zaninotto
  • 7,068
  • 2
  • 35
  • 56