monglow
TypeScript icon, indicating that this package has built-in type declarations

4.1.0 • Public • Published

monglow

A simple MongoDB wrapper that doesn't get in your way.

  • Easy & flexible database setup
  • Command buffering (query without waiting for connection)
  • Promises built-in
  • Direct access to native MongoDB driver
  • Serverless friendly
  • Typescript support
npm i --save monglow

Usage

import { Monglow, Model } from 'monglow';
 
const uri = 'localhost/test';
const monglow = new Monglow(uri);
 
interface IUser {
  firstName: string;
  lastName: string;
}
 
const User = new Model<IUser>('users');
 
/**
 * You can activate and use your models at any point in the code and
 * Monglow will automatically handle the connection process
 */
monglow.activate(User);
 
User.find().then(users => {
  console.log(users);
});
 
// Direct access to MongoDB driver
User.collection.then(c => c.find({ hello: 'world!' }).count());
 
// You can also activate models with connectAndActivate so
// you don't need to run connect at the start of the code.
monglow.connectAndActivate(User);
// Note: this function can be called many times without
// any problems, the database will only connect once per instance of Monglow
 
monglow.connect();
 
//
//
// Do some things
//
//
 
monglow.close();

Readme

Keywords

Package Sidebar

Install

npm i monglow

Weekly Downloads

0

Version

4.1.0

License

MIT

Unpacked Size

13.1 kB

Total Files

9

Last publish

Collaborators

  • thomasraydeniscool