@@ -80,31 +80,36 @@ export class ArrayCursor<T = any> {
8080 }
8181
8282 /**
83- * TODO
83+ * The total number of documents in the query result. Only available if the
84+ * `count` option was used.
8485 */
85- get count ( ) {
86+ get count ( ) : number | undefined {
8687 return this . _count ;
8788 }
8889
8990 /**
90- * TODO
91+ * Whether the cursor has any remaining batches that haven't yet been
92+ * fetched. If set to `false`, all batches have been fetched and no
93+ * additional requests to the server will be made when consuming any
94+ * remaining items from this cursor.
9195 */
9296 get hasMore ( ) : boolean {
9397 return this . _hasMore ;
9498 }
9599
96100 /**
97- * TODO
101+ * Whether the cursor has more values. If set to `false`, the cursor has
102+ * already been depleted and contains no more items.
98103 */
99104 get hasNext ( ) : boolean {
100105 return this . hasMore || Boolean ( this . _result . length ) ;
101106 }
102107
103108 /**
104- * Enables use with `for await` to exhaust the cursor by asynchronously
109+ * Enables use with `for await` to deplete the cursor by asynchronously
105110 * yielding every value in the cursor's remaining result set.
106111 *
107- * **Note**: If the result set spans multiple batches, any unfetched batches
112+ * **Note**: If the result set spans multiple batches, any remaining batches
108113 * will only be fetched on demand. Depending on the cursor's TTL and the
109114 * processing speed, this may result in the server discarding the cursor
110115 * before it is fully depleted.
@@ -129,7 +134,14 @@ export class ArrayCursor<T = any> {
129134 }
130135
131136 /**
132- * TODO
137+ * Depletes the cursor, then returns an array containing all values in the
138+ * cursor's remaining result list.
139+ *
140+ * @example
141+ * ```js
142+ * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);
143+ * const result = await cursor.all(); // [1, 2, 3, 4, 5]
144+ * console.log(cursor.hasNext); // false
133145 */
134146 async all ( ) : Promise < T [ ] > {
135147 await this . _drain ( ) ;
@@ -139,7 +151,22 @@ export class ArrayCursor<T = any> {
139151 }
140152
141153 /**
142- * TODO
154+ * Advances the cursor and returns the next value in the cursor's remaining
155+ * result list, or `undefined` if the cursor has been depleted.
156+ *
157+ * **Note**: If the result set spans multiple batches, any remaining batches
158+ * will only be fetched on demand. Depending on the cursor's TTL and the
159+ * processing speed, this may result in the server discarding the cursor
160+ * before it is fully depleted.
161+ *
162+ * @example
163+ * ```js
164+ * const cursor = await db.query(aql`FOR x IN 1..3 RETURN x`);
165+ * const one = await cursor.next(); // 1
166+ * const two = await cursor.next(); // 2
167+ * const three = await cursor.next(); // 3
168+ * const empty = await cursor.next(); // undefined
169+ * ```
143170 */
144171 async next ( ) : Promise < T | undefined > {
145172 while ( ! this . _result . length && this . hasMore ) {
@@ -152,7 +179,27 @@ export class ArrayCursor<T = any> {
152179 }
153180
154181 /**
155- * TODO
182+ * Advances the cursor and returns all remaining values in the cursor's
183+ * current batch. If the current batch has already been exhausted, fetches
184+ * the next batch from the server and returns it, or `undefined` if the
185+ * cursor has been depleted.
186+ *
187+ * **Note**: If the result set spans multiple batches, any remaining batches
188+ * will only be fetched on demand. Depending on the cursor's TTL and the
189+ * processing speed, this may result in the server discarding the cursor
190+ * before it is fully depleted.
191+ *
192+ * @example
193+ * ```js
194+ * const cursor = await db.query(
195+ * aql`FOR i IN 1..10 RETURN i`,
196+ * { batchSize: 5 }
197+ * );
198+ * const firstBatch = await cursor.nextBatch(); // [1, 2, 3, 4, 5]
199+ * await cursor.next(); // 6
200+ * const lastBatch = await cursor.nextBatch(); // [7, 8, 9, 10]
201+ * console.log(cursor.hasNext); // false
202+ * ```
156203 */
157204 async nextBatch ( ) : Promise < any [ ] | undefined > {
158205 while ( ! this . _result . length && this . hasMore ) {
0 commit comments