0.0.9 • Published 10 years ago

tpc-dataservice v0.0.9

Weekly downloads
2
License
MIT
Repository
github
Last release
10 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

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago