skip to Main Content

Mongodb – Upsert many documents based on _id

I need to upsert many documents based on _id. E.g. document_1 = {_id:"1", "age":11, "name":"name1"} document_2 = {_id:"2", "age":22, "name":"name2"} I wrote the below db.my_collection.updateMany( { _id: {"$in":["1","2"] } }, [ {$set: {_id:"1", "age":11, "name":"name1"}}, {$set: {_id:"2", "age":22, "name":"name2"}} ],…

VIEW QUESTION

Mongodb aggregation to find outliers

In my mongodb collection documents are stored in the following format: { "_id" : ObjectId("62XXXXXX"), "res" : 12, ... } { "_id" : ObjectId("63XXXXXX"), "res" : 23, ... } { "_id" : ObjectId("64XXXXXX"), "res" : 78, ... } ... I…

VIEW QUESTION

Mongodb – How to remove double quotes inside double quotes in string field?

Currently a document looks like this: { "Post": "this is a post", "_id": ObjectId("630f3c32c1a580642a9ff4a0"), "iframe": ""https:/www.youtube.com/embed/RzVvThhjAKw"", "slug": "this-is-a-title", "title": "This is a title" } But I want it like this: { "Post": "this is a post", "_id": ObjectId("630f3c32c1a580642a9ff4a0"), "iframe": "https:/www.youtube.com/embed/RzVvThhjAKw",…

VIEW QUESTION
Back To Top
Search