useMongocampBulkByFilter
Count, delete and update by the Lucene filter of the document list — one request each. No ids are collected, so there is no cap, no id snapshot and nothing to chunk.
const { countDocuments, deleteByFilter, updateByFilter } = useMongocampBulkByFilter()
const n = await countDocuments('orders', 'status:open') // POST …/documents/count, filter in the body
const deleted = await deleteByFilter('orders', 'status:cancelled') // DELETE …/documents/many/delete?filter= (body {})
const { matched, modified } = await updateByFilter('orders', 'status:open', { status: 'archived' })
const open = await countDocuments('orders', 'name:ali*', { filterCaseInsensitive: true, signal })| Function | Returns |
|---|---|
countDocuments(collection, filter?, options?) | the number of matching documents |
deleteByFilter(collection, filter?, options?) | the server's deletedCount |
updateByFilter(collection, filter, document, options?) | { matched, modified }; document is set on every match ($set) |
options is { signal?, filterCaseInsensitive? } — or, as before, an AbortSignal on its own. filterCaseInsensitive: true matches the filter's wildcards without regard to case (the server matches them case-sensitively otherwise); MongocampCollectionData sets it for a wildcard filter unless Match case is on.
Empty filter
An empty filter would touch the whole collection. The server only does that with matchAll=true, so the composable sends it exactly when the filter is empty — the caller's own confirmation (the typed collection name in MongocampCollectionData) is the guard.
Server facts
The Lucene filter goes in the request body as $lucene (server 3.0: { $lucene } for delete, { document, filter: { $lucene } } for update), so it has no length limit; filterCaseInsensitive stays a query parameter. A filter in both places is refused with 400; no filter at all without matchAll is 400, code 4003. A filter that matches nothing changes nothing. The server loads the matching documents for its events, so very large matches use memory in proportion.