1.0.0 • Published 6 years ago

connectors v1.0.0

Weekly downloads
41
License
ISC
Repository
-
Last release
6 years ago

Database Connectors

Nodejs unify database connectors

npm package issues pull requests bitHound Overall Score bitHound Code

How to

npm install connectors
// define array of connection info
let database = [
    {
        connector_name: 'mongoose',
        host: '127.0.0.1',
        port: '27017',
        db_name: 'db_test'
    }
];

// require somewhere globally during application start/setup/init
require('connectors').init(database);

// and use like that in your model:
const {mongoose} = require('connectors');
// or
db.rabbitmq.sendToQueue('queue_name', new Buffer('something...'))

Settings Configuration Example

const settings = [
    {
        connector_name: 'mongoose',
        host: 'localhost',
        port: '',
        db_name: ''
    },
    {
        connector_name: 'mysql',
        host: 'localhost',
        port: '',
        db_name: ''
    }
];

TODO: 1. support multi connection at the same db. 2. connect all configured db at once(async). 3. consider if i need mysql + redis export in index.js 4. mongoose promise is dep: "(node:11663) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html"