@nanomatic/mongodb
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

String to object

@nanomatic/mongodb

Status License


Library that allows to manage MongoDB database

📝 Table of Contents

🏁 Getting Started

Installing

npm i @nanomatic/mongodb

Using

Example code below:

import { MongoDB } from '@nanomatic/mongodb';

const db = 'db';
const collection = 'test';

// tslint:disable-next-line: no-console
const showDocuments = async(mongoDB: MongoDB) => console.log(await mongoDB.getDocuments(db, collection));

new MongoDB('localhost', 27017, async(mongoDB: MongoDB) => {
    try {
        // Clear database
        await mongoDB.removeDocuments(db, collection);

        await mongoDB.insertDocument(db, collection, { vehicle: '🚑'});
        await mongoDB.insertDocument(db, collection, { vehicle: '🚒'});
        await showDocuments(mongoDB);

        await mongoDB.updateDocuments(db, collection, { vehicle: '🚑'}, { vehicle: '🚓'});
        await mongoDB.removeDocuments(db, collection, { vehicle: '🚒'});
        await showDocuments(mongoDB);
    } catch {
        // tslint:disable-next-line: no-console
        console.log('😥');
    }
});

⛏️ Built With

✍️ Authors

🎉 Acknowledgments

  • Special thanks for Sebastian for working together and giving ideas 😉

Package Sidebar

Install

npm i @nanomatic/mongodb

Homepage

nanomatic.pl

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

10.4 kB

Total Files

4

Last publish

Collaborators

  • nano_matic