0

MongoDB Admin

by
Published Jan 17, 2023

Admin panel for the sample Customers dataset of MongoDB Cloud

App mongodb Verified

The app

Static preview only: No backend
This is a static preview of the app and there is no backend. As such, the interactivity requiring script execution is non functional. To see the fully functional app, edit/run it in Windmill by clicking the button above.

Scripts used

import { Resource } from "https://deno.land/x/[email protected]/mod.ts";
import { MongoClient, ObjectId } from "https://deno.land/x/[email protected]/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)
  })
}