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).
We are still working on removing the nested lists limitation, but on a related note â Device Sync has support for querying on GeoJSON Points now! An engineer on the team wrote a nice blog post about it here: Introducing Sync for Geospatial Data | MongoDB.
Can find the Kotlin docs here, as well as docs on how to structure GeoJSON Points here.
Hi Jonathan,
Thank you for the reply and suggested resources. They are proving helpful to solve a part of my use case.
However, I am in the process of creating a brand new application and am in the design process. It would be amazing to structure my database data as GeoJSON from the start and not rework the whole database structure later on. The data i am working with will include polygons, linestrings and points (already implemented as GeoPoint).
Is there a an estimated release for this feature?
Will it be in the next few months or are we talking year(s)?