How can i remove a value from an array which is nested

in this i want to remove value from column1 taskIds.

Hi @kuldeep_saini, welcome to the community.
Please take a look at the $pull operator.
$pull will remove the specified value from the array.

db.stores.update(
    { <---- Your filter ----> },
    { $pull: { "order.columns.column1.taskIds": "<---- The value that you want to be removed ----> "},
)

In case you are not sure which specific value you want to remove from the array, but just want to remove the first or last value in the array you can use $pop operator.

To remove the first element in the array:

db.stores.update(
    { <---- Your filter ----> },
    { $pop: { "order.columns.column1.taskIds": -1 },
)

To remove the last element in the array:

db.stores.update(
    { <---- Your filter ----> },
    { $pop: { "order.columns.column1.taskIds": 1 },
)

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha

Thanks @SourabhBagrecha it worked .
i will reach to you again if i stuck in somewhere. :relaxed:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.