MongoDB + Node.js + Express + D3
MongoDB + Node.js + Express
npm install -g mongoviewer-serverStart your MongoViewer API Server:
mongoviewer-serverBy default it will serve on port 8080: http://localhost:8080/.
See configuration options for customizing your API server.
Example customized:
mongoviewer-server --server:port 8081 --mongo:database testDbSee the API documentation for more details.
MongoDB + Node.js + Express + D3
npm install
bower installnode index.jsUses nconf.
See the default configuration file at default_config.json.
Alternatively you can use additional command line arguments:
--server:port 8080- Default8080.--server:CORS 1- Defaulttrue(1),falseis0.--mongo:port 27017- Default27017--mongo:database mongoviewer- Default ismongoviewer.
For example:
node index.js --server:port 8081 --mongo:database testDb/api/v1/
See db.collection.find.
GET /api/v1/:collection/find
- query
- options
GET /api/v1/:collection/findOne
- query
- options
GET /api/v1/:collection/aggregate
- pipeline
- options
node load.jsFrom MongoDB example dataset: http://docs.mongodb.org/manual/tutorial/aggregation-zip-code-data-set/
mongoimport -db mongoviewer -c zips < example_data/zips.json node index.jsThis will start the server. Now you can view at http://localhost:8080/.
Request: http://localhost:8080/api/v1/discreteBar/find?query={"label":"A Label"}
Response:
[
{
"label": "A Label",
"value": -29.765957771107,
"_id": "532e5294c1f6d3f17df677ba"
}
]Request: http://localhost:8080/api/v1/discreteBar/findOne?query={"label":"A Label"}
Response:
{
"label": "A Label",
"value": -29.765957771107,
"_id": "532e5294c1f6d3f17df677ba"
}Request: http://localhost:8080/api/v1/discreteBar/aggregate?pipeline=[{"$match":{"label":"A Label"}}]
Response:
[
{
"label": "A Label",
"value": -29.765957771107,
"_id": "532e5294c1f6d3f17df677ba"
}
]

