Suggestion for alternate API for $unset

Current way of working with $unset is as:

db.movieDetails.updateOne({“title”:“The Martian”},{$unset:{“tomato.userReviews”:""}})

Won’t it be better to have something like what we have with projection in find API, wherein we use 1 and 0 to indicate target fields.

db.movieDetails.updateOne({“title”:“The Martian”},{$unset:{“tomato.userReviews”:1}})

Hi @Manish_75171,

In terms of MongoDB, it does not matter if we use “” or 1 with $unset operator as it does not actually care about the target value("" or 1).
For more information about the $unset operator, please refer to the following documentation:

Moreover, this is the default behaviour of the database or the driver designed to support the database.

If you have any further doubt, please let me know.
Your efforts and suggestions are highly appreciated!!


What I meant to say is that current way conveys different meaning. Proposed way is much more intuitive to a programmer. An intuitive API is always adopted easily.