Remove data
Removal is one of the easiest things to do in Orama. Let’s say we have the following database with the following inserted documents:
To remove a single document from the database we use the:
As simple as that.
Batch removal
Most of the remove
function internals are synchronous, so removing a large
number of documents in a loop could potentially block the event loop. If you
have a lot of records, we suggest using the removeMultiple
function.
You can pass a third, optional, parameter to change the batch size (default:
1000
). We recommend keeping this number as low as possible to avoid blocking
the event loop. The batchSize
refers to the maximum number of remove
operations to perform before yielding the event loop.
The function returns the number of the removed documents.