Complete the code to mark a document as deleted by setting the 'deleted' field to true.
db.users.updateOne({ _id: userId }, { $set: { deleted: [1] } })Setting the 'deleted' field to true marks the document as soft deleted.
Complete the query to find only documents that are not soft deleted.
db.users.find({ deleted: [1] })Documents with 'deleted' set to false are active (not deleted).
Fix the error in the update query to soft delete a document by setting 'deleted' to true.
db.users.updateOne({ _id: userId }, { $set: { deleted: [1] } })The value should be the boolean true, not a string or number.
Fill both blanks to query active users and sort them by creation date descending.
db.users.find({ deleted: [1] }).sort({ createdAt: [2] })We find users where 'deleted' is false (active users) and sort by 'createdAt' descending using -1.
Fill all three blanks to update a document's 'deleted' status, set 'deletedAt' timestamp, and exclude deleted documents in a query.
db.users.updateOne({ _id: userId }, { $set: { deleted: [1], deletedAt: [2] } });
db.users.find({ deleted: [3] })Set 'deleted' to true and 'deletedAt' to the current date. Then query documents where 'deleted' is false to exclude deleted ones.