Skip to content

Commit

Permalink
Add support for withHidden in collection.indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
pluma4345 committed May 15, 2024
1 parent 8e48d93 commit 8e83105
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ This driver uses semantic versioning:

Inlining this dependency should help make arangojs more portable.

### Added

- Added support for `withHidden` option in `collection.indexes`

This option was introduced in ArangoDB 3.10.13 and 3.11.7 and allows
fetching the progress information of indexes that are in the building phase.

## [9.0.0-preview.1]

This is a major release and breaks backwards compatibility.
Expand Down
23 changes: 20 additions & 3 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2561,14 +2561,31 @@ export interface DocumentCollection<T extends Record<string, any> = any>
/**
* Returns a list of all index descriptions for the collection.
*
* @param withHidden - If set to `true`, includes indexes that are not yet
* fully built but are in the building phase. Default: `false`.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const indexes = await collection.indexes();
* ```
*/
indexes(): Promise<Index[]>;
indexes(withHidden?: boolean): Promise<Index[]>;
/**
* Returns a list of all index descriptions for the collection.
*
* @param withHidden - If set to `true`, includes indexes that are not yet
* fully built but are in the building phase. Default: `false`.
*
* @example
* ```js
* const db = new Database();
* const collection = db.collection("some-collection");
* const indexes = await collection.indexes(true);
* ```
*/
indexes(withHidden?: boolean): Promise<(Index & { progress: number })[]>;
/**
* Returns an index description by name or `id` if it exists.
*
Expand Down Expand Up @@ -4161,11 +4178,11 @@ export class Collection<T extends Record<string, any> = any>
//#endregion

//#region indexes
indexes() {
indexes(withHidden = false) {
return this._db.request(
{
path: "/_api/index",
search: { collection: this._name },
search: { collection: this._name, withHidden: String(withHidden) },
},
(res) => res.parsedBody.indexes
);
Expand Down

0 comments on commit 8e83105

Please sign in to comment.