Skip to content

Commit 5ccfe4c

Browse files
committed
Add ignoreRevs to RemoveDocumentOptions
Fixes DE-947.
1 parent dec0293 commit 5ccfe4c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ This driver uses semantic versioning:
1414
- A change in the major version (e.g. 1.Y.Z -> 2.0.0) indicates _breaking_
1515
changes that require changes in your code to upgrade.
1616

17+
## [Unreleased]
18+
19+
### Added
20+
21+
- Added `ignoreRevs` option to `RemoveDocumentOptions` type (DE-947)
22+
23+
This affects the `collection.remove` and `collection.removeAll` methods.
24+
1725
## [10.0.0] - 2025-01-06
1826

1927
This is a major release and breaks backwards compatibility.
@@ -2452,6 +2460,7 @@ For a detailed list of changes between pre-release versions of v7 see the
24522460

24532461
Graph methods now only return the relevant part of the response body.
24542462

2463+
[unreleased]: https://github.com/arangodb/arangojs/compare/v10.0.0...HEAD
24552464
[10.0.0]: https://github.com/arangodb/arangojs/compare/v9.3.0...v10.0.0
24562465
[9.3.0]: https://github.com/arangodb/arangojs/compare/v9.2.0...v9.3.0
24572466
[9.2.0]: https://github.com/arangodb/arangojs/compare/v9.1.0...v9.2.0

src/documents.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,13 @@ export type RemoveDocumentOptions = {
372372
* Default: `false`
373373
*/
374374
waitForSync?: boolean;
375+
/**
376+
* If set to `false`, the existing document will only be modified if its
377+
* `_rev` property matches the same property on the new data.
378+
*
379+
* Default: `true`
380+
*/
381+
ignoreRevs?: boolean;
375382
/**
376383
* If set to `true`, the complete old document will be returned as the `old`
377384
* property on the result object. Has no effect if `silent` is set to `true`.
@@ -573,7 +580,7 @@ export type ObjectWithDocumentKey = {
573580
export function _documentHandle(
574581
selector: DocumentSelector,
575582
collectionName: string,
576-
strict: boolean = true,
583+
strict: boolean = true
577584
): string {
578585
if (typeof selector !== "string") {
579586
if (selector._id) {
@@ -583,14 +590,14 @@ export function _documentHandle(
583590
return _documentHandle(selector._key, collectionName);
584591
}
585592
throw new Error(
586-
"Document handle must be a string or an object with a _key or _id attribute",
593+
"Document handle must be a string or an object with a _key or _id attribute"
587594
);
588595
}
589596
if (selector.includes("/")) {
590597
const [head] = selector.split("/");
591598
if (strict && head !== collectionName) {
592599
throw new Error(
593-
`Document ID "${selector}" does not match collection name "${collectionName}"`,
600+
`Document ID "${selector}" does not match collection name "${collectionName}"`
594601
);
595602
}
596603
return selector;

0 commit comments

Comments
 (0)