@nanomatic/mongodb
v1.0.0
Published
Library that allows to manage MongoDB database
Downloads
3
Readme
📝 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
- ts-node-dev - TypeScript Node Dev
- tsc-watch - The nodemon for TypeScript
- TSLint - TypeScript linter
- NodeJs - Test Environment
✍️ Authors
- @NANOmatic - Idea & Initial work
🎉 Acknowledgments
- Special thanks for Sebastian for working together and giving ideas 😉