0.0.3 • Published 5 years ago

@xorb/mongo v0.0.3

Weekly downloads
42
License
ISC
Repository
github
Last release
5 years ago

Mongo

Minimal MongoDB client.

Example usage

Prerequisites

  • npm or yarn
yarn add @xorb/mongo
 # or you can use
npm install @xorb/mongo --save

Usage

// index.js
import { mongo } from "@xorb/mongo";

const uri = "mongo://";

async function drop() {
  try {
    const db = await mongo.connect(uri);
    // connected to database, do something is needed
    const data = await db.collection("todos").find();
  } catch {
    // Something went wrong
  }
}

// controller.js
import { mongo } from "@xorb/mongo";

async function createTodo() {
  try {
    const db = await mongo.getDb();
    const res = db.collection("todos").insertOne(todo);
    // do more
  } catch {
    // handle errors
  }
}

Contribute

I would really like a comments. So you can fork this repository and leave a PR with comments. Thanks.

Author

Created and maintained by Dany Boza (@xorbmoon).

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

1.0.0

5 years ago