1 | import { MongoClient } from "https://deno.land/x/atlas_sdk@v1.0.3/mod.ts"; |
2 |
|
3 |
|
4 | * @param data_source For example: `Cluster0` |
5 | * |
6 | * @param filter For example: `{ "_id": "01234" }` |
7 | * Find out more at: |
8 | * https://www.mongodb.com/docs/manual/reference/method/db.collection.deleteMany/ |
9 | */ |
10 | type MongodbRest = { |
11 | endpoint: string; |
12 | api_key: string; |
13 | }; |
14 | export async function main( |
15 | auth: MongodbRest, |
16 | data_source: string, |
17 | database: string, |
18 | collection: string, |
19 | filter: Record<string, any>, |
20 | ) { |
21 | const client = new MongoClient({ |
22 | endpoint: auth.endpoint, |
23 | dataSource: data_source, |
24 | auth: { apiKey: auth.api_key }, |
25 | }); |
26 | const documents = client.database(database).collection(collection); |
27 | return await documents.deleteMany(filter); |
28 | } |
29 |
|