I am trying to delete multiple documents of a particular collection meeting certain criteria. Ideally after deleting these documents I need to add new documents. Even though the new documents are added successfully to the collections, when it comes to deletion only one document is deleted. Any help in the right direction is appreciated.
I have tried different combinations of async and await, but didn't work. Just to let you know, I am using the same session for both addition and deletion calls. Below is the method for deleting multiple documents accepting 'session' as an argument.
export async function deleteDocs(session: IDocumentSession, docs: IDoc[]) {
docs.forEach(doc => {
session.delete<Doc>(doc);
});
await session.saveChanges();
}
I should be able to delete all documents matching the criteria, and not just one.