N
N
NetyNicka2017-02-16 13:08:54
Yii
NetyNicka, 2017-02-16 13:08:54

Are there any examples of implementing "nested" APIs in Yii2?

There are just a huge number of examples of API implementation on the Internet:
1) api/users/{user_id}/posts/{post_id}/comments/{comment_id} everything is simple and clear here.
2) But there are also api documentation examples where data is nested in a shared object:
api/user

{
  "id": 1,
  "user_email": "[email protected]",
  "posts": [
    {
      "id": 1,
      "text": "....",
      "comments": [
        {
          "id": 1,
          "author": "guest",
          "message": "..."
        }
      ]
    }
  ]
}

However, I can not find examples of working with attachments from 2 examples, not only on yii2, but also on other frameworks.
I would like to know what are the advantages of 2 solutions over 1 (after all, they use the same), and how to handle this correctly / gracefully, because simple cycles with model-> load && save raise doubts about the adequacy of the solution.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
davidnum95, 2017-02-16
@NetyNicka

The first is used for updating, deleting, adding data, the second for displaying. What is the question then?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question