I want to insert new objects into a MongoDB document's array field.
Initially it look like this:
I want to insert a new Object into "notifications" (Array) field.
After upsert, It should look like this:
I'm using below format code
# conn_usr is a mongolite's mongo connection object
conn_usr$update(query = '{ "user": "user" }',
update = '{ "$set": {"notifications":[{"key1": "x", "key2": "y"}] } }',
upsert = TRUE ) #
This code replaces the first item, not inserting into "notifications" field.
Any help is appreciated.