Hi guys,
I make a API using CakePHP 3.2.x, so, and now have a angular app requesting API.
My question is about association data, e.g. i have Series Model and send the request:
api.com/series/add
{
"id": 5,
"title": "New serie",
"hidden": false,
"courses": {"_ids":["1","2"]}
}
It's work, many times, i have problems, because first time in edit, i get register and mockup in scope of app, and have problems, because register have all fields, per sample:
1. Avoiding Mass Assignment Protection in Entity, because save created = null
2. Send all object data, have association data i don't want send, i need using transformRequest in angularJs
3. Many times i have problem with CORS, because send a object complex, not expected, if simple object it's work
4. I have problem for delete association data, have a garbage in docs, but not work's 100%. [1]
So, this easy save data and associations, now, it's my nightmare.
My point is about best practices for api, i read articles and have a solution, using sub resources.
I need create new endpoints for retrieve/save/delete associations data in register ?
What do you think ? Thank you in advance for your attention
[1] http://book.cakephp.org/3.0/en/orm/saving-data.html#patching-hasmany-and-belongstomany
--
-- I make a API using CakePHP 3.2.x, so, and now have a angular app requesting API.
My question is about association data, e.g. i have Series Model and send the request:
api.com/series/add
{
"id": 5,
"title": "New serie",
"hidden": false,
"courses": {"_ids":["1","2"]}
}
It's work, many times, i have problems, because first time in edit, i get register and mockup in scope of app, and have problems, because register have all fields, per sample:
1. Avoiding Mass Assignment Protection in Entity, because save created = null
2. Send all object data, have association data i don't want send, i need using transformRequest in angularJs
3. Many times i have problem with CORS, because send a object complex, not expected, if simple object it's work
4. I have problem for delete association data, have a garbage in docs, but not work's 100%. [1]
So, this easy save data and associations, now, it's my nightmare.
My point is about best practices for api, i read articles and have a solution, using sub resources.
I need create new endpoints for retrieve/save/delete associations data in register ?
What do you think ? Thank you in advance for your attention
[1] http://book.cakephp.org/3.0/en/orm/saving-data.html#patching-hasmany-and-belongstomany
--
Regards,
Rafael F. Queiroz
Rafael F. Queiroz
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup
We will soon be closing this Google Group. But don't worry, we have something better coming. Stay tuned for an updated from the CakePHP Team soon.
Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment