Skip to content

Commit 5319228

Browse files
committed
add support for creating and dropping collection
1 parent 4edb1ac commit 5319228

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/collections/client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {createAstraUri, createNamespace, parseUri} from './utils';
1717
import { HTTPClient } from '@/src/client';
1818
import { logger } from '@/src/logger';
1919
import {Collection} from "./collection";
20+
import {CreateCollectionOptions} from "./options";
2021

2122
export interface ClientOptions {
2223
applicationToken?: string;
@@ -84,6 +85,14 @@ export class Client {
8485
return new Collection(this.httpClient, name);
8586
}
8687

88+
async createCollection(collectionName: string, options?: CreateCollectionOptions) {
89+
return await this.db().createCollection(collectionName, options);
90+
}
91+
92+
async dropCollection(collectionName: string,) {
93+
return await this.db().dropCollection(collectionName);
94+
}
95+
8796
/**
8897
* Connect the MongoClient instance to JSON API (create Namespace automatically when the 'createNamespaceOnConnect' flag is set to true)
8998
* @returns a MongoClient instance

0 commit comments

Comments
 (0)