Hello,
I would like to create a subscription by filtering my object by the user id using a backlink query but i get the following error :
{“code”: 1016, “isOk”: false, “reason”: “Invalid query: embedded field found in query. embedded fields can not be queryable: "@links.User.pets._id"”}
my subscription is :
useEffect(() => {
const createSubscription = async () => {
await realm.subscriptions.update((mutableSubs) => {
mutableSubs.add(
realm
.objects("Pet").filtered('ANY @links.User.pets._id = $0',props.user._id),
{ name: "PetSubscription" }
);
}
);
}
createSubscription().catch(console.error);
}, []);
My User Object :
export class User extends Realm.Object {
static schema = {
name: "User",
properties: {
_id: "objectId" ,
name: "string?",
firstName: "string?",
lastName: "string?",
picture: "string?",
email: "string?",
pets:"Pet[]",
},
primaryKey: "_id",
};
}
My Pet Object
export class Pet extends Realm.Object {
static schema = {
name: "Pet",
properties: {
_id: { type: "objectId", default: () => new Realm.BSON.ObjectId() },
name: { type: "string", default: () => "Wafme" },
age: { type: "int", default: () => 0 },
sex: { type: "bool", default: () => true },
size: { type: "int", default: () => 0 },
picture: {type:"object", objectType: "Picture"},
coordinate: "Coordinate?",
},
primaryKey: "_id",
};
}
The error talks about embedded object while i dont have any embedded object.
I would like to have all the Pets owned by the user id
how should i update the following query to make it work?
filtered(‘ANY @links.User.pets._id = $0’,props.user._id)
Best regards