transactions-express-rest-mongodb
v0.1.47
Published
A backend plugin to transactions-express for implementing the rest apis system with a mongodb data system
Downloads
100
Readme
transactions-express-rest-mongodb
Documentation comes soon... You can see for now how the simple tests work for understanding the (de)lightness of the api.
require('babel-polyfill') const express = require('express') const http = require('http') const { MongoClient } = require('mongodb') const { useRouter } = require('transactions-express-rest-mongodb')
const app = express()
MongoClient.connect('mongodb://localhost:27017/demo') .then(({ db }) => {
// use here the transactions middleware with a certain api path useRouter(app, { db, routePath: '/data' })
http.Server(app) .listen(5000, function () { console.log('Server available at http://0.0.0.0:5000') }) })
mongo demo --eval "db.authors.insert([{ name: 'Karl' }, { name: 'Albert' }])"
require('babel-polyfill')
const express = require('express')
const http = require('http')
const { MongoClient } = require('mongodb')
const { useRouter } = require('transactions-express-rest-mongodb')
const app = express()
MongoClient.connect('mongodb://localhost:27017/demo')
.then(({ db }) => {
// use here the transactions middleware with for a certain api path
useRouter(app, { db, routePath: '/data' })
http.Server(app)
.listen(5000, function () {
console.log('Server available at http://0.0.0.0:5000')
})
})
curl -X GET "http://localhost:5000/data/authors"
curl -X PUT -H "Content-Type: application/json" -d '{ "query": { "name": "Albert" }, "update": { "name": "Robert" } }' "http://localhost:5000/data/authors"