Admin panel for the sample Customers dataset of MongoDB Cloud
import { Resource } from "https://deno.land/x/windmill@v1.86.0/mod.ts";
import { MongoClient, ObjectId } from "https://deno.land/x/atlas_sdk@v1.1.1/mod.ts";
/**
* @param data_source For example: `Cluster0`
*
* @param filter For example: `{ "_id": "01234" }`
* Find out more at:
* https://www.mongodb.com/docs/manual/reference/method/db.collection.deleteOne/
*/
export async function main(
auth: Resource<"mongodb_rest">,
data_source: string,
database: string,
collection: string,
document_id: string
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const documents = client.database(database).collection(collection)
return await documents.deleteOne({
_id: new ObjectId(document_id)
})
}