Skip to content

Commit c922a6c

Browse files
committed
a little bit of typing changes
1 parent ad6f7f5 commit c922a6c

File tree

6 files changed

+37
-7
lines changed

6 files changed

+37
-7
lines changed

src/data-api/collection.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,10 +1418,12 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
14181418
* console.log(options.vector);
14191419
* ```
14201420
*
1421+
* @param options - The options for this operation.
1422+
*
14211423
* @return The options that the collection was created with (i.e. the `vector` and `indexing` operations).
14221424
*/
1423-
async options(): Promise<CollectionOptions<SomeDoc>> {
1424-
const results = await this._db.listCollections({ nameOnly: false });
1425+
async options(options?: WithTimeout): Promise<CollectionOptions<SomeDoc>> {
1426+
const results = await this._db.listCollections({ nameOnly: false, maxTimeMS: options?.maxTimeMS });
14251427

14261428
const collection = results.find((c) => c.name === this.collectionName);
14271429

src/data-api/db.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { AstraDbAdmin, mkDbAdmin } from '@/src/devops/astra-db-admin';
2828
import { AdminSpawnOptions, DbSpawnOptions, RootClientOptsWithToken } from '@/src/client';
2929
import { RunCommandOptions } from '@/src/data-api/types/collections/command';
3030
import { WithTimeout } from '@/src/common/types';
31+
import { DropCollectionOptions } from '@/src/data-api/types/collections/drop-collection';
3132

3233
/**
3334
* @internal
@@ -206,8 +207,8 @@ export class Db implements Disposable {
206207
*
207208
* @throws Error - if the database is not an Astra database.
208209
*/
209-
public async info(): Promise<DatabaseInfo> {
210-
return await this.admin().info().then(i => i.info);
210+
public async info(options?: WithTimeout): Promise<DatabaseInfo> {
211+
return await this.admin().info(options).then(i => i.info);
211212
}
212213

213214
/**
@@ -341,7 +342,7 @@ export class Db implements Disposable {
341342
*
342343
* @remarks Use with caution. Have steel-toe boots on. Don't say I didn't warn you.
343344
*/
344-
public async dropCollection(name: string, options?: WithTimeout & WithNamespace): Promise<boolean> {
345+
public async dropCollection(name: string, options?: DropCollectionOptions): Promise<boolean> {
345346
const command = {
346347
deleteCollection: { name },
347348
};

src/data-api/types/collections/command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
import { WithNamespace } from '@/src/data-api';
16+
import { WithTimeout } from '@/src/common';
1617

1718
/**
1819
* Options for executing some arbitrary command.
@@ -22,7 +23,7 @@ import { WithNamespace } from '@/src/data-api';
2223
*
2324
* @see Db.command
2425
*/
25-
export interface RunCommandOptions extends WithNamespace {
26+
export interface RunCommandOptions extends WithNamespace, WithTimeout {
2627
/**
2728
* The collection to run the command on. If not provided, the command is run on the database.
2829
*/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright DataStax, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import { WithNamespace } from '@/src/data-api';
16+
import { WithTimeout } from '@/src/common/types';
17+
18+
/**
19+
* Options for dropping a collection.
20+
*
21+
* @field namespace - Overrides the namespace for the collection.
22+
* @field maxTimeMS - The maximum time to allow the operation to run.
23+
*
24+
* @see Db.dropCollection
25+
*/
26+
export interface DropCollectionOptions extends WithTimeout, WithNamespace {}

src/data-api/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export * from './collections/collections-common';
1616
export * from './collections/collection-options';
1717
export * from './collections/create-collection';
1818
export * from './collections/list-collection';
19+
export * from './collections/drop-collection';
1920
export * from './collections/command';
2021
export * from './delete/delete-many';
2122
export * from './delete/delete-one';

src/devops/types/admin/list-databases.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
import { DatabaseCloudProvider, DatabaseStatus, } from '@/src/devops/types';
16-
1716
import { WithTimeout } from '@/src/common/types';
1817

1918
export type DatabaseStatusFilter = DatabaseStatus | 'ALL' | 'NONTERMINATED';

0 commit comments

Comments
 (0)