jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
284 stars 64 forks source link

Add new key to documents wherever it doesn't exist #196

Open mansi-aggarwal-2504 opened 4 years ago

mansi-aggarwal-2504 commented 4 years ago

My code looks like this: training_status <- mongo(collection = flag, db = database)

training_status$update(query = paste0('{"EndTime": { "$exists" : "',FALSE,'" }}'), update = paste0('{"$set":{"EndTime":"', Sys.time(),'"}}"'), multiple = FALSE)

I want to update the document where end time key doesn't exist with the data time stamp but this doesn't seem to work. Can someone help?

Thanks in advance.