Again I’m running into an issue where I just don’t quite understand how to do very Realm-y things in the Realm functions. Hoping for some better documentation soon.
I have a trigger that fires when a user updates their name, which is in their User object in their “user=User_id” partition.
So the change event is the user object with the updated name.
@Andrew_Morgan helped me in another forum post see how to add a Hunter object to my Hunt realm object here:
In my function I am able to generate the _id of the embedded object which is lives in Hunt.hunters.
I have attempted the following, but can’t seem to get the syntax right:
const hunterQuery = { "hunters": { "_id": idCode }};
const hunterUpdate = {
"$set": {
"hunter.name": result.name,
"hunter.email": result.email
}
};
const huntOptions = { returnNewDocument: true };
huntsCollection.findOneAndUpdate(hunterQuery, hunterUpdate, huntOptions);
I have console logged and verified that the idCode
is correct for the embedded object, but I’m assuming that I either need to adjust the hunterQuery
or the hunterUpdate
in order to write to the embedded object.
This is what the embedded object looks like in Atlas:
Any pointers or even where to find any info about Realm Functions and Embedded Objects would be awesome. Thanks!
–Kurt