@tomsd/mongodbclient

It's a handy mongodb client for easy-use.
See npm @tomsd/mongodbclient also.

npm NPM

ci checks top language Maintenance depends on mongodb@6 depends on node greater or equal 18

installation

npm install @tomsd/mongodbclient

usage

MClient is exported from the package.

import { MClient } from "@tomsd/mongodbclient";

const [ uri, dbName, collectionName ] = [
  "mongodb+srv://...",
  "dbName",
  "collectionName"
];

const mdbc = new MClient(uri, dbName, collectionName);

const items = [
  { name: "alice" },
  { name: "bob" }
];

console.log(
  await mdbc.insertMany(items)
    .then(({ insertedCount}) => insertedCount)
); // 2

const docs = await mdbc.read();
await mdbc.upsert({
  ...docs[0],
  name: "charlie"
});