4.1.5 • Published 3 months ago

@tomsd/mongodbclient v4.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@tomsd/mongodbclient

It's a handy mongodb client for easy-use.
See mongodbclient.netlify.app for details.

npm NPM

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

Installation

npm install @tomsd/mongodbclient

Usage

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

const uri = "mongodb+srv://...";
const dbName = "mydb";
const collectionName = "mycollection";

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

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

(async () => {
  const { insertedCount } = await mdbc.insertMany(items);
  console.log(insertedCount); // 4

  const docs = await mdbc.read();
  console.log(docs);

  const { upsertedCount, modifiedCount } = await mdbc.upsert({
    ...docs[0],
    name: "david"
  });
  console.log(`upsertedCount: ${upsertedCount}, modifiedCount: ${modifiedCount}`);

  const names = await mdbc.distinct("name");
  console.log(`distinct names: ${names.length}`); // 4

  const itemLength = await mdbc.count();
  console.log(`count: ${itemLength}`); // 4

  const { deletedCount } = await mdbc.remove({});
  console.log(`deletedCount: ${deletedCount}`); // 4

})();
4.1.5

3 months ago

4.1.4

3 months ago

4.1.3

4 months ago

4.1.2

4 months ago

4.1.1

5 months ago

4.1.0

5 months ago

4.0.4

6 months ago

4.0.3

6 months ago

4.0.1

7 months ago

4.0.2

7 months ago

3.0.13

1 year ago

3.0.14

1 year ago

4.0.0

1 year ago

3.0.12

2 years ago

3.0.9

3 years ago

3.0.10

3 years ago

3.0.11

3 years ago

3.0.8

3 years ago

2.3.0

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.5.0

3 years ago

2.4.0

3 years ago

2.2.2

3 years ago

2.7.0

3 years ago

2.6.0

3 years ago

2.8.1

3 years ago

2.7.2

3 years ago

2.8.0

3 years ago

2.7.1

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

2.7.4

3 years ago

2.7.3

3 years ago

2.7.6

3 years ago

2.7.5

3 years ago

3.0.0

3 years ago

2.7.8

3 years ago

2.7.7

3 years ago

2.7.9

3 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago