Reputation: 61
How can I delete file.txt when I delete Folder1 in mongoDB and nodejs ?
[
{
_id: 1,
name: Folder1,
parentId: null
},
{
_id: 2,
name: file.txt,
parentId: 1
},
]
Upvotes: 0
Views: 368
Reputation: 98
you can Delete a Document , for example You can specify the document or documents to be deleted by the deleteOne() or deleteMany() write operations in a JSON object as follows:
const doc = {
pageViews: {
$gt: 10,
$lt: 32768
}
};
To delete the first matching document using the deleteOne() method or to delete all matching documents using the deleteMany() method, pass the document as the method parameter:
const deleteResult = await collection.deleteOne(doc);
const deleteManyResult = await collection.deleteMany(doc);
Upvotes: 1