transactions-express-rest-mongodb

0.1.47 • Public • Published

transactions-express-rest-mongodb

npm version

icon icon A backend plugin to transactions-express for implementing the rest apis system with a mongodb data system.

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"

Readme

Keywords

none

Package Sidebar

Install

npm i transactions-express-rest-mongodb

Weekly Downloads

48

Version

0.1.47

License

MIT

Last publish

Collaborators

  • ledoux