I have a field which is a two dimensional array that I am trying to build into a schema. The field is a set of x,y coordinates, e.g. [[1.0,1.0],[2.0,2.0],[3.0,3.0]].
Hi, Realm DB does not support storing lists of lists unfortunately at the moment. Using that JSON Schema will actually make the collection by “sync invalid”. We are currently in the process of trying to remove this limitation and have better support for geospatial data, so stay tuned for announcements on that.
Hi, I have no immediate update to share, but we have a project currently underway that should solve this issue in a more general way. Stay tuned for more!
In the interim, here is the solution we’re deploying:
remove the GeoJSON from the app services schema.
create a custom resolver with the parent being the object and name it the same (so if the field is geometry, call it geometry)
Have the custom resolver return { coodinates: JSON.stringify(item.coordinates) }
In your client app (assuming Apollo Client) create a new ApolloLink to automatically JSON.parse the geometry nodes.
Create a schema for geometryString.
On mutations, take your geometry $set and change it to {geometryString: JSON.stringify(item.geometry)}
Create a trigger on INSERT,UPDATE,REPLACE that watches for geometryString and have it delete that value and set {geometry: JSON.parse(item.geometryString)}
Wish you weren’t using app services at all.
Hope this helps anyone still waiting on MongoDB to implement nested arrays!
It looks like you’re using GraphQL. I believe nested arrays work with App Services and GraphQL, just not (yet) with Atlas Device Sync (which is what the original question was asking about).
They have not worked for me. You can generate a schema with GeoJSON data and it will generate a broken schema (that will have no error but will be unavailable to query).