1.1.0 • Published 11 years ago
mongo-restful v1.1.0
mongo-restful
A very simple RESTful MongoDB proxy.
Allows you to query a MongoDB database over HTTP:
MongoDB <--- HTTP --> BrowserLimitations
Currencyly the API is read-only. Feel free to do a pull request :)
Installation
Install as a global binary:
npm install -g mongo-restfulInclude into your own server:
npm install --save mongo-restfulCLI
Just run the following command:
mongo-restful [options] [arguments]Specify the MongoDB URI as the first argument to the mongo-restful command.
Options:
--port- specify which port the HTTP server should run on (defaults to 8080)
Example:
mongo-restful --port 3000 localhost/my-databaseIntegration
You can also integrate mongo-restful into your exsiting node project:
var mongoUri = 'localhost/my-database';
var proxy = require('mongo-restful')(mongoUri);
proxy.listen(8080, function () {
console.log('The MongoDB proxy is running on port 8080');
});REST API
Query a collection:
GET /my-collection?q=...Use query parameters to filter your query. All query parameters are optional, but if none are given the entire collection is retuned!
Query parameters:
- q: The MongoDB query. Use MongoDB Extended JSON syntax, e.g.
{"createdAt":{"$date":"2014-01-01T00:00:00Z"}} - filter: Optional projection, e.g.
{"foo":1} - sort: Optional sorting object, e.g.
{"bar":-1} - limit: Return only n results
- skip: Skip n results
Request a specific document:
GET /my-collection/idNote: It's expected that id is a MongoDB ObjectId.
License
MIT
