Skip to content

Commit 9250c32

Browse files
matchomchouet
and
mchouet
authored
Fix #630 - trigger collection compaction (#756)
Co-authored-by: mchouet <mathias.chouet@inria.fr>
1 parent 39d5a33 commit 9250c32

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/collection.ts

+22
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,18 @@ export interface DocumentCollection<T extends Record<string, any> = any>
25932593
dropIndex(
25942594
selector: IndexSelector
25952595
): Promise<ArangoResponseMetadata & { id: string }>;
2596+
/**
2597+
* Triggers compaction for a collection.
2598+
*
2599+
* @example
2600+
* ```js
2601+
* const db = new Database();
2602+
* const collection = db.collection("some-collection");
2603+
* await collection.compact();
2604+
* // Background compaction is triggered on the collection
2605+
* ```
2606+
*/
2607+
compact(): Promise<ArangoResponseMetadata>;
25962608
//#endregion
25972609
}
25982610

@@ -4042,5 +4054,15 @@ export class Collection<T extends Record<string, any> = any>
40424054
new BatchedArrayCursor(this._db, res.body, res.arangojsHostId).items
40434055
);
40444056
}
4057+
4058+
compact() {
4059+
return this._db.request(
4060+
{
4061+
method: "PUT",
4062+
path: `/_api/collection/${this._name}/compact`
4063+
},
4064+
(res) => res.body
4065+
);
4066+
}
40454067
//#endregion
40464068
}

0 commit comments

Comments
 (0)