Support Questions
Find answers, ask questions, and share your expertise

How to update mongo db document for only perticular fields?

Highlighted

How to update mongo db document for only perticular fields?

New Contributor

Hi,

I am having one use case where I will get JSON from kafka consumer and I will have to upsert same docs in mongodb. Catch is , kafka publisher will send only few fields which are changed at my source DB and I need to sync those updated values in target mongodb. I tried to search but couldn't find any particular way to update few fields . All I can see is insert or update whole document in mongo db based on key provided.

Any ideas would be appreciated!! Thank you.

-Vishal

2 REPLIES 2
Highlighted

Re: How to update mongo db document for only perticular fields?

Highlighted

Re: How to update mongo db document for only perticular fields?

New Contributor

Hi @Haijme, Yes correct. I am looking for "$set" like functionality