0.0.9 • Published 8 years ago

tpc-dataservice v0.0.9

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Build Status Coverage Status #tpc-dataservice

A simple MongoDB based Data Service utility.

Installation

npm install tpc-dataservice --save

Configuration

Setup the Environment

Set the environment variables

NODE_ENV=development
MONGODB_URI=mongodb://localhost:27017
SCHEMA_FILE=./resources/service.schema.js
SCHEMA_NAME=users

Usage

The usage of the data service utility is pretty straight forward.

var dataService=require('tpc-dataservice');

//Connect to a database
dataService.connect(function(result){
    console.log(JSON.stringify(result));
});

//To get all entries from a collection
dataService.all(function(result){
    console.log(JSON.stringify(result));
});

//To create a new entry
var entry={first_name:'John', last_name:'Smith'};
dataService.create(entry, function(result){
    console.log(JSON.stringify(result));
});

//To read an entry
var id=4815162342;
dataService.read(id, function(result){
    console.log(JSON.stringify(result));
});

//To update an entry
var id=4815162342;
var updates={first_name:'John', last_name:'Doe'};
dataService.update(id, udpates, function(result){
    console.log(JSON.stringify(result));
});

//To remove an entry
var id=4815162342;
dataService.delete(id, function(result){
    console.log(JSON.stringify(result));
});

That's all folks!

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago