I am encountering a strange behavior accessing embedded models. It might be the way I am structuring things but basically I have a model with an "embedsOne" relation and that model that is embedded has an "embedsMany" relation.
I have successfully created the "embedsOne" model and added a single record to that model's "embedsMany" collection.
User:
"relations": {
"provider": {
"type": "embedsOne",
"model": "Provider",
"property": "providerAccount",
"options": {
"validate": true,
"forceId": false
}
}
}
Provider:
"relations": {
"allRatings": {
"type": "embedsMany",
"model": "Rating",
"property": "allUserRatings",
"options": {
"forceId": false,
"validate": true
}
}
}
GET
RESULT
[
{
"rating": 4,
"comment": "This rocks!!",
"username": "Jack",
"userId": 1,
"id": 1
}
]
However, when I do a COUNT:
GET
RESULT
{
"count": 0 <--- count is zero!
}
I'm a bit confused as to why this is happening, seems like I should be getting consistent results through these different APIs based on the model.