@@ -10,11 +10,11 @@ If _config_ is a string, it will be interpreted as _config.url_.
1010
1111** Arguments**
1212
13- * ** config** : ` Object ` (optional)
13+ - ** config** : ` Object ` (optional)
1414
1515 An object with the following properties:
1616
17- * ** url** : ` string | Array<string> ` (Default: ` http://localhost:8529 ` )
17+ - ** url** : ` string | Array<string> ` (Default: ` http://localhost:8529 ` )
1818
1919 Base URL of the ArangoDB server or list of server URLs.
2020
@@ -36,14 +36,14 @@ If _config_ is a string, it will be interpreted as _config.url_.
3636 }
3737 ```
3838
39- * ** isAbsolute** : ` boolean` (Default: ` false` )
39+ - ** isAbsolute** : ` boolean` (Default: ` false` )
4040
4141 If this option is explicitly set to ` true` , the _url_ will be treated as the
4242 absolute database path . This is an escape hatch to allow using arangojs with
4343 database APIs exposed with a reverse proxy and makes it impossible to switch
4444 databases with _useDatabase_ or using _acquireHostList_.
4545
46- * **arangoVersion**: `number` (Default: ` 30000` )
46+ - **arangoVersion**: `number` (Default: ` 30000` )
4747
4848 Value of the `x-arango-version` header. This should match the lowest
4949 version of ArangoDB you expect to be using. The format is defined as
@@ -57,14 +57,14 @@ If _config_ is a string, it will be interpreted as _config.url_.
5757 not available on every major version of ArangoDB as indicated in their
5858 descriptions below (e .g . _collection .first_ , _collection .bulkUpdate_ ).
5959
60- * **headers**: `Object` (optional)
60+ - **headers**: `Object` (optional)
6161
6262 An object with additional headers to send with every request.
6363
6464 Header names should always be lowercase. If an `"authorization"` header is
6565 provided, it will be overridden when using _useBasicAuth_ or _useBearerAuth_.
6666
67- * **agent**: `Agent` (optional)
67+ - **agent**: `Agent` (optional)
6868
6969 An http Agent instance to use for connections.
7070
@@ -74,7 +74,7 @@ If _config_ is a string, it will be interpreted as _config.url_.
7474
7575 This option has no effect when using the browser version of arangojs.
7676
77- * **agentOptions**: `Object` (Default: see below)
77+ - **agentOptions**: `Object` (Default: see below)
7878
7979 An object with options for the agent. This will be ignored if _agent_ is
8080 also provided.
@@ -91,15 +91,41 @@ If _config_ is a string, it will be interpreted as _config.url_.
9191 additional options to the underlying calls of the
9292 [` xhr` ](https://www.npmjs.com/package/xhr) module.
9393
94- * **loadBalancingStrategy**: ` string` (Default: ` " NONE" ` )
94+ - **loadBalancingStrategy**: ` string` (Default: ` " NONE" ` )
9595
96- Determines the behaviour when multiple URLs are provided:
96+ Determines the behavior when multiple URLs are provided:
9797
98- * ` NONE ` : No load balancing. All requests will be handled by the first
98+ - ` NONE ` : No load balancing. All requests will be handled by the first
9999 URL in the list until a network error is encountered. On network error,
100100 arangojs will advance to using the next URL in the list.
101101
102- * ` ONE_RANDOM ` : Randomly picks one URL from the list initially, then
102+ - ` ONE_RANDOM ` : Randomly picks one URL from the list initially, then
103103 behaves like ` NONE ` .
104104
105- * ` ROUND_ROBIN ` : Every sequential request uses the next URL in the list.
105+ - ` ROUND_ROBIN ` : Every sequential request uses the next URL in the list.
106+
107+ ## database.close
108+
109+ ` database .close (): void `
110+
111+ Closes all active connections of the database instance.
112+ Can be used to clean up idling connections during longer periods of inactivity.
113+
114+ **Note**: This method currently has no effect in the browser version of arangojs.
115+
116+ **Examples**
117+
118+ ` ` ` js
119+ const db = new Database ();
120+ const sessions = db .collection (" sessions" );
121+ // Clean up expired sessions once per hour
122+ setInterval (async () => {
123+ await db .query (aql`
124+ FOR session IN ${ sessions}
125+ FILTER session.expires < DATE_NOW()
126+ REMOVE session IN ${ sessions}
127+ ` );
128+ // Make sure to close the connections because they're no longer used
129+ db .close ();
130+ }, 1000 * 60 * 60 );
131+ ```
0 commit comments