Skip to content

Commit

Permalink
Add missing options
Browse files Browse the repository at this point in the history
Fixes DE-940. Fixes DE-945. Fixes DE-946. Fixes DE-947.
  • Loading branch information
pluma4345 committed Nov 20, 2024
1 parent f22e90f commit 7938a14
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ This driver uses semantic versioning:
This property is always present if the error has a `response` property. In
normal use this should always be the case.

- Added `keepNull` option to `CollectionInsertOptions` type (DE-946)

This option was previously missing from the type.

- Added `allowDirtyRead` option to `DocumentExistsOptions` type (DE-945)

This option was previously missing from the type.

- Added `ignoreRevs` option to `CollectionBatchReadOptions` type (DE-947)

This option was previously missing from the type.

- Added `options` argument to `CollectionTruncateOptions` type (DE-940)

There was previously no way to pass options to the `truncate` method.

- Added `database` property to `Analyzer`, `ArrayCursor`, `BatchedArrayCursor`,
`Collection`, `Graph`, `Job`, `Route`, `Transaction` and `View` types (DE-935)

Expand Down
40 changes: 38 additions & 2 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,21 @@ export type CollectionChecksumOptions = {
withData?: boolean;
};

/**
* Options for truncating collections.
*/
export type CollectionTruncateOptions = {
/**
* Whether the collection should be compacted after truncation.
*/
compact?: boolean;
/**
* Whether data should be synchronized to disk before returning from this
* operation.
*/
waitForSync?: boolean;
};

/**
* Options for dropping collections.
*/
Expand Down Expand Up @@ -623,6 +638,12 @@ export type CreateCollectionOptions = {
* Options for checking whether a document exists in a collection.
*/
export type DocumentExistsOptions = {
/**
* If set to `true`, the request will explicitly permit ArangoDB to return a
* potentially dirty or stale result and arangojs will load balance the
* request without distinguishing between leaders and followers.
*/
allowDirtyRead?: boolean;
/**
* If set to a document revision, the document will only match if its `_rev`
* matches the given revision.
Expand Down Expand Up @@ -673,6 +694,13 @@ export type CollectionBatchReadOptions = {
* request without distinguishing between leaders and followers.
*/
allowDirtyRead?: boolean;
/**
* If set to `false`, the existing document will only be modified if its
* `_rev` property matches the same property on the new data.
*
* Default: `true`
*/
ignoreRevs?: boolean;
};

/**
Expand Down Expand Up @@ -715,6 +743,13 @@ export type CollectionInsertOptions = {
* Default: `"conflict"
*/
overwriteMode?: "ignore" | "update" | "replace" | "conflict";
/**
* If set to `false`, properties with a value of `null` will be removed from
* the new document.
*
* Default: `true`
*/
keepNull?: boolean;
/**
* If set to `false`, object properties that already exist in the old
* document will be overwritten rather than merged when an existing document
Expand Down Expand Up @@ -1306,7 +1341,7 @@ export interface DocumentCollection<
* // the collection "some-collection" is now empty
* ```
*/
truncate(): Promise<ArangoApiResponse<CollectionMetadata>>;
truncate(options?: CollectionTruncateOptions): Promise<ArangoApiResponse<CollectionMetadata>>;
/**
* Deletes the collection from the database.
*
Expand Down Expand Up @@ -2896,10 +2931,11 @@ export class Collection<
return result;
}

truncate(): Promise<ArangoApiResponse<CollectionMetadata>> {
truncate(options?: CollectionTruncateOptions): Promise<ArangoApiResponse<CollectionMetadata>> {
return this._db.request({
method: "PUT",
path: `/_api/collection/${this._name}/truncate`,
search: options,
});
}

Expand Down

0 comments on commit 7938a14

Please sign in to comment.