@marcj/marshal-mongo
v2.1.13
Published
Marshal's Mongo database management.
Downloads
143
Readme
Mongo Database for Marshal
Marshal's MongoDB database abstraction makes it super easy to retrieve and store data from and into your MongoDB. We make sure the data from your JSON or class instance is correctly converted to MongoDB specific types and inserted IDs are applied to your class instance.
npm install @marcj/marshal @marcj/marshal-mongo reflect-metadata mongodb
import {Database, Connection} from "@marcj/marshal-mongo";
const database = new Database(new Connection('localhost', 'mydb', 'username', 'password'));
const instance = new SimpleModel('My model');
await database.add(instance);
const list = await database.query(SimpleModel).find();
const oneItem = await database.query(SimpleModel).filter({id: 'f2ee05ad-ca77-49ea-a571-8f0119e03038'}).findOne();