How to delete data from Vector Search in Mongodb

39 Views Asked by At

I have created a vector search index on my collection in MongoDB, Now I want to delete some data from it let's say data is added with bookId=1, I tried deleting the data with

db.collection('inventory').deleteMany({"bookId":"1"});

But it's not deleted, Also Find() is also not returning the data.

1

There are 1 best solutions below

0
Atique On BEST ANSWER

you need to use async await for the same. Either use the statement in an async function

async function deleteData() {
     const res = await db.collection('inventory').deleteMany({"bookId":"1"});
     console.log(result)
}

or you can use callback.

db.collection('inventory').deleteMany({"bookId":"1"}).then((result) => {
     console.log(result);
})