A
A
Actor2013-08-01 10:08:39
Angular
Actor, 2013-08-01 10:08:39

REST Models and Relationships

Hello, show an example of a correct model with connections.
For example, there are orders and services for these orders
Models Order, Service (the same is on the server, there is a third OrderServices to connect these models)
According to the REST principle, to add service 8 to order 3, what needs to be done?
If you write like this:
POST /orders/3/services/8
That means changing service 8 for service 3.

What if you need to add a comment to service 8 for order 3?

If you just need to change the state on off again POST / orders / 3 do?

how is it done in AngularJS?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
EugeneOZ, 2013-08-01
@EugeneOZ

One hassle with these nested addresses, it's much easier for each resource to have its own entry point.
AngularJS has a special $resource for working with REST.
If it doesn't work with $resource, you can use regular $http.

A
Actor, 2013-08-02
@Actor

And now how to register all this in the AngularJS model?
$resource('/api/orders/:orderId/:action/:serviceID', ...)
right?

K
Konstantin Kitmanov, 2013-08-01
@k12th

POST /orders/3/services {serviceId: 8}, it seems. And for change - PATCH.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question