$unset
$unset is a keyword used by MongoDB
to remove keys from the document. You can use the same keyword in
mongoSheet also to remove any particular key from your document.
Consider a document schema as shown below. We are using the schema to store details on products in an online store
Consider a document schema as shown below. We are using the schema to store details on products in an online store
{ productId: // string title: // string images: // array discription: // string offerPercent: // number }
After some days in production, you wanted to remove the
offerPercent
from some of the products as they are not more in the sale. If the
situation was to remove offerPercent from all the documents in
the collection then there are MongoDB shell commands which can help you.
But here we only want to remove
offerPercent
from some of the products.
To do that add $unset to the column
and then run the UPDATE command. The key
offerPercent
will be removed from all the specified documents.