My /api/orders.json
api look like:
{
"data": {
"id": "46636",
"type": "order",
"attributes": {
"number": "12",
"category": "out"
},
"relationships": {
"lists": {
"data": [
{
"id": "443",
"type": "lists"
}
]
}
}
}
}
And they will find list
from /api/lists/443
:
{
"data": {
"id": "443",
"type": "list",
"attributes": {
"number": "1",
"category": "black"
}
}
}
There are everything is good. But my case is in the example above, my list
is the sum of the need, not every one of the list. Just like:
{
"data": {
"id": "1",
"type": "list",
"attributes": {
"number": "1",
"category": "black"
}
}
}
{
"data": {
"id": "2",
"type": "list",
"attributes": {
"number": "1",
"category": "black"
}
}
}
{
"data": {
"id": "2",
"type": "list",
"attributes": {
"number": "1",
"category": "red"
}
}
}
Modified into(User sum
, group
and select
SQL
):
{
"data": {
"id": "xx",
"type": "list",
"attributes": {
"number": "2",
"category": "black"
}
}
}
{
"data": {
"id": "xx",
"type": "list",
"attributes": {
"number": "1",
"category": "red"
}
}
}
The problem is if I use group
data's id is null and can not find the data. Because relatationships' data must find by id
.
How do I solve this problem? I find a way to solve is use javascript like: http://ift.tt/1f0jdd4 . I think it will have another better to solve this problem. Thinks.
Aucun commentaire:
Enregistrer un commentaire