I have two fields I am trying to use to build a document filter (in App Services > Rules) for the Item collection.
One is a UUID (the _id of the Item document). The other is an array of UUID stored on the users profile.
This is the filter in its current form:
{
"collaborator_id": {
"$in": "%%user.custom_data.collaborators"
}
}
It saves fine, but when I try to run the app and sync, it gives me an error “$in needs an array”:
ending session with error: error bootstrapping new query: error querying state store: error while querying the state collection "state_Item": (BadValue) $in needs an array (ProtocolErrorCode=201)
SCHEMAS:
Item:
{
"title": "Item",
"type": "object",
"required": [
"_id",
"isComplete",
"owner_id",
"partnership_id",
"summary"
],
"properties": {
"_id": {
"bsonType": "uuid"
},
"isComplete": {
"bsonType": "bool"
},
"owner_id": {
"bsonType": "string"
},
"partnership_id": {
"bsonType": "uuid"
},
"summary": {
"bsonType": "string"
}
}
}
User:
{
"title": "User",
"properties": {
"_id": {
"bsonType": "objectId"
},
"partnerships": {
"bsonType": "array",
"items": {
"bsonType": "uuid"
}
}
}
}
EXAMPLES:
Here is a raw example of Item:
{
"_id":{
"$binary":{
"base64":"TJiWdUgvTWOrNhZOCWhj6g==",
"subType":"04"
}
},
"isComplete":false,
"owner_id":"652c671990aad0d369d94434",
"collaborator_id":{
"$binary":{
"base64":"kYpeWOOlQ0iox5macnFfCw==",
"subType":"04"
}
},
"summary":"Ffff"
}
Here is a raw example of User (what is used for the user custom data):
{
"_id":{
"$oid":"652ddf6afda42fb20153d562"
},
"partnerships":[
{
"$binary":{
"base64":"kYpeWOOlQ0iox5macnFfCw==",
"subType":"04"
}
}
]
}