You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@webgap/database-dao

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webgap/database-dao

Database data access object abstraction module.

0.1.2
latest
Source
npmnpm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

WebGAP Database DAO

Build Status Test Coverage Code Climate Dependency Status

NPM version NPM downloads

README

This is the WebGAP DatabaseDAO module.
Handles abstraction for multiple database systems.

Dependencies

Handles logging using @webgap/logger.
Loads default configuration using @webgap/configuration.
MongoDB Driver mongodb.
JSON File System @webgap/jsonfs.

Requirements

A configuration file must exist (check @webgap/configuration documentation).

API

Installation

npm install @webgap/database-dao --save

Usage

// using jsondbfs driver
var options = {
  databaseDriver: 'jsondbfs', 
  collectionName: 'UserCollection', 
  connectionString: '/path/to/store/json/files'
};
var UserDAO = new DAO(options);
UserDAO.getClient(function (err, client) {
  client.insert({name: "teste", age: 33}, callback);
  client.createIndex({name: "teste"}, callback);
  client.find({name: "teste"}, callback);
  client.findOne({name: "teste"}, callback);
  client.findAndModify({name: "teste"}, {name: "teste", age: 34},callback);
  client.update({name: "teste"}, {name: "teste1", age: 33},callback);
  client.remove({name: "teste1", age: 33}, callback);
});

// or using mongodb driver
var options = {
  databaseDriver: 'mongodb', 
  collectionName: 'UserCollection', 
  connectionString: 'mongodb://user:pass@host:port'
};
var UserDAO = new DAO(options);
UserDAO.getClient(function (err, client) {
  client.insert({name: "teste", age: 33}, callback);
  client.createIndex({name: "teste"}, callback);
  client.find({name: "teste"}, callback);
  client.findOne({name: "teste"}, callback);
  client.findAndModify({name: "teste"}, {name: "teste", age: 34},callback);
  client.update({name: "teste"}, {name: "teste1", age: 33},callback);
  client.remove({name: "teste1", age: 33}, callback);
});

Options

The object 'options' should contain (at least) the following attributes:

var options = {
  collectionName: 'name'  //the name of the collection
};

Other options include:

var options = {
  databaseDriver: 'jsondbfs', //one of mongodb or jsondbfs
  connectionString: '/tmp' // the path to the database. if jsonfs is a filesystem location otherwise if is mongodb should be a mongo db url: mongodb://user:pass@host:port
};

If no 'options' is provided, the module will try to load the settings from @webgap/configuration module.

DB.DRIVER - Defaults to 'jsondbfs'
DB.CONNECTION_STRING - Defaults to '/tmp/'

License

Apache License, Version 2.0

Keywords

webgap

FAQs

Package last updated on 09 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.