Code Monkey home page Code Monkey logo

mongodb-rest's Introduction

Name

mongodb-rest - REST server for MongoDB

Description

This is a REST server for MongoDB using Node, using the native node.js MongoDB driver. Using Express, it can now start in any folder and will happily server any files a public folder.

Installation

Installation is now via npm: npm install mongodb-rest. After that you can just issue mongodb-rest on the command line and the server should start.

Try

After installation you can quickly try whether it works by issuing the following from the command line:

curl -d '{ "A1" : 201 }' -H "Content-Type: application/json" http://localhost:3000/test/example1

This should add a document to the "test" db.example1 collection: { "A1": 201, "_id": ObjectId("4e90e196b0c7f4687000000e") }

Notes

Supported REST requests:

  • GET /db/collection - Returns all documents
  • GET /db/collection?query=%7B%22isDone%22%3A%20false%7D - Returns all documents satisfying query
  • GET /db/collection?query=%7B%22isDone%22%3A%20false%7D&limit=2&skip=2 - Ability to add options to query (limit, skip, etc)
  • GET /db/collection/id - Returns document with id
  • POST /db/collection - Insert new document in collection (document in POST body)
  • PUT /db/collection/id - Update document with id (updated document in PUT body)
  • DELETE /db/collection/id - Delete document with id

Flavors:

  • Setup "sproutcore" as flavor, it will then change _id as returned by MongoDB into guid, as used by SproutCore, this allows for simpler DataSources.
  • Setup "nounderscore" as flavor, it will then change _id into id.

Content Type:

  • Please make sure application/json is used as Content-Type when using POST/PUT with request body's.

Dependencies:

  • Are all indicated in package.json. So far I indicate the lowest version with which I tested the code. Sadly this can result in non-working code when later versions are used.

Testing

Testing is now done using expresso. Just run the following in the main folder: expresso -s test/create.test.js test/delete.test.js test/update.test.js The SproutCore test needs to be run separately at the moment.

Future

  • REST - PUT /db/collection - Update whole collection with changes in PUT body
  • Other useful commands (quit, reconnect, addUser, removeUser, etc)

Credits

mongodb-rest's People

Contributors

blakmatrix avatar samyakbhuta avatar tdegrunt avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.