Hi there,
i’m experiencing with flexiblke sync and i try to undestend how relationships works.
Consider this two schema:
Facility is the table in which are collected some facilities and they can be of different types, so i make a relationship with Facility and Types
Facility schema and relationship with Type
{
"_facId": {
"ref": "#/relationship/mongodb-atlas/facilities/Types",
"foreignKey": "_id",
"isList": false
}
}
{
"title": "Facility",
"bsonType": "object",
"required": [
"owner_id",
"_facId"
],
"properties": {
"_id": {
"bsonType": "objectId"
},
"_facId": {
"bsonType": "long"
},
"owner_id": {
"bsonType": "long"
},
"facName": {
"bsonType": "string"
},
"facDescrizione": {
"bsonType": "string"
},
"type": {
"bsonType": "long"
}
}
}
Type Schema
{
"title": "Type",
"bsonType": "object",
"required": [
"_id",
"nome"
],
"properties": {
"_id": {
"bsonType": "long"
},
"tipo": {
"bsonType": "string"
},
"descrizione": {
"bsonType": "string"
},
"nome": {
"bsonType": "string"
}
}
}
And here is the first thing i didn’t undestand: from the manual a read that
To-one relationships must be optional
When you declare a to-one relationship in your object model, it must be an optional property. If you try to make a to-one relationship required, Realm throws an exception at runtime.
But if i take out _facId from required i got this error on UI inteface
failed to get queryable fields by table: field "_facId" in table "Facility" is not an allowed queryable field: queryable field cannot be a cross-collection link
So i made that field as required.
Client side (Java SDK) i use this subscritpion that works fine without relationships
Subscription subscription = realm.getSubscriptions().find(realm.where(Facility.class)
.equalTo("owner_id", 0));
but i got this error:
E/REALM_JAVA: Session Error[wss://realm.mongodb.com/]: BAD_QUERY(realm::sync::ProtocolError:226): Invalid query (IDENT, QUERY): failed to parse query: query contains table not in schema: “Facility” Logs: xxxxxxxxxxxxx
Where do i mistake?
Thank you in advance