1.0.3 • Published 8 years ago

crud.js v1.0.3

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

crud.js

crud.js easily install crud on your node server Based only on mongoDB

Installation

npm install crud.js

Crud.js

var bodyParser      = require('body-parser');
var express         = require('express');
var cors            = require('cors');

var MongoClient = require('mongodb').MongoClient;

var crud = require('crud.js');

var port = 5000;
var app = module.exports = express();
var url = 'mongodb://localhost:27017/test';

app.use(cors());
app.use(bodyParser.json({limit: '1mb'}));
app.use(bodyParser.urlencoded({limit: '1mb', extended: false}));

MongoClient.connect(url, function(err, client) {
    if (err) {
        console.log(err);
    } else {
        console.log('successful connection on mongoDB ', url);
        crud.init(client); // initialize the database on crud Object
    }
});

app.all('/crud/:collection?', crud.crud);

app.listen(port, function() {
    console.log('Server on http://localhost:' + port);
});
  

Notes

If you want to only manage specific collections you have to add it on lib/crud.js on the variable mappingCollection. It will be extended on the futurs realase.