Hey Kyle, no worries at all, thanks for getting back.
I’ll check out the new version of the docs, that could definitely be helpful. Removing the babel plugin seems like a good call to me, bouncing back and forth between the typescript syntax and the static schema syntax was confusing. Add on top of that a different syntax in Atlas app services - JSON schema as it seems to be called - and it’s difficult to figure out how to do what you’re trying to do, or even where to do so (on the front-end or in Atlas). Some information regarding relationships was written in the JSON schema syntax (eg the syntax you see in Atlas app services), which made it really unclear if that’s what I needed to use in the front-end. Can’t say exactly where I encountered that, some information seems to be spread between different SDKs (or was).
Anyways, the point of that was just to communicate that 3 similar and not clearly differentiated schema syntaxes was a stumbling point, so getting the Babel/TypeScript version out of the mix seems helpful.
I still have not been able to clarify “the way” to create an object in Realm with a relationship property if you could chime in on that, it might be helpful to have in the CRUD docs too. By relationship property I mean the one-to-one or one-to-many relationships (not an embedded object) described here.
- To use the example in the docs, PetOwnerhas a a property{ pet: 'Pet?' }. In order toRealm.create()aPetOwner, my experience has been that you need to pass the entire relatedPetobject in to the constructor. Is that the case? For example:
realm.create('PetOwner', {
  name: 'Alice',
  birthDate: new Date('1987-01-01'),
  pet: {
    _id: aBsonId,
    name: 'Spot',
    age: 7,
    animalType: 'Dog'
})
- This seems weird to me, I would expect to be able to pass the ID - that is after all what is stored. I could not find anywhere in the docs that addresses it (that was a little while ago now). Not a huge issue though, as you can just go get the object from realm and pass it to create.
- I haven’t tested what happens if you try a make a pet owner with pet data that doesn’t match the data in the database, maybe it will throw?
- Just as a personal note, overall I’m leaning away from using relationships. It seems like the benefit is mostly convenience, since we’re not saving network requests by joining as we would with a remote database. And from what I can tell, relationships only exist in Realm, not Mongo/Atlas, so you wouldn’t be able to use it in network queries anyway. In particular the problem outlined here makes it so this convenience is leaking into the data model itself, which is less than ideal. I haven’t tried using a related object with a related object, but this would naturally come up in my app, and it seems like the brittleness will just increase…