Giter VIP home page Giter VIP logo

mongoo's Introduction

Mongoo

This module is meant to dynamically load and connect to a mongo database implementing mongoose and including any schemas from the schema folder.

Methods

init(options) initializes the class with the config you pass in. Useful if you don't want to set environment variables for whatever reason.

{
    "user": "admin",
	"pass": "password",
	"replicaSet": "replica_name",
	"database": "db_name",
	"host": "localhost:27027"
}

open [Promise] opens a connection to the mongo database. The opened mongoose connection is stored on the client member and sets the status to open

const db = require('mongoo');
if (db.status === 'closed') await db.open().catch(console.log);
let object = await db.client.find({ id: 1235897 });

close [Promise] closes the connection stored on the client member, if it exists.

const db = require('mongoo');
if (db.status === 'open') await db.close().catch(console.log);

getSchemas scans the current directory for a /schemas/ folder and adds them to the current instantiation of mongoose. Schemas should be stored as json objects with or without a .json extension

main

const db = require('mongoo');
db.getSchemas();
let Dog = new db.schemas.animal({ family: 'Canidae', genus: 'Canis' });
Dog.save(err => console.log(err));
// or
db.schemas.animal.create({ family: 'Canidae', genus: 'Canis' });

animal.json

{
    "family": String,
	"genus": String
}

mongoo's People

Contributors

jaydenrasmussen avatar

Watchers

James Cloos avatar  avatar

Forkers

fossabot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.