mongoviewer-server

MongoDB + Node.js + Express + D3

Usage no npm install needed!

<script type="module">
  import mongoviewerServer from 'https://cdn.skypack.dev/mongoviewer-server';
</script>

README

MongoViewer NPM version

MongoDB + Node.js + Express + D3

NPM


Install API Server CLI

MongoDB + Node.js + Express

npm install -g mongoviewer-server

Usage

Start your MongoViewer API Server:

mongoviewer-server

By 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 testDb

See the API documentation for more details.


Developing MongoViewer

MongoDB + Node.js + Express + D3

screenshot

Installation

npm install
bower install

Usage

node index.js

Configuration

Uses nconf.

See the default configuration file at default_config.json.

Alternatively you can use additional command line arguments:

  • --server:port 8080 - Default 8080.
  • --server:CORS 1 - Default true (1), false is 0.
  • --mongo:port 27017 - Default 27017
  • --mongo:database mongoviewer - Default is mongoviewer.

For example:

node index.js --server:port 8081 --mongo:database testDb

API

Version 1

/api/v1/

Find

See db.collection.find.

GET /api/v1/:collection/find
Query Parameters:
  • query
  • options

FindOne

See db.collection.findOne.

GET /api/v1/:collection/findOne
Query Parameters:
  • query
  • options

Aggregate

See db.collection.aggregate.

GET /api/v1/:collection/aggregate
Query Parameters:
  • pipeline
  • options

Example API Usage

Load the example dataset, discreteData

node load.js

Start the Server

node index.js

This will start the server. Now you can view at http://localhost:8080/.

Example find API Query

Request: http://localhost:8080/api/v1/discreteBar/find?query={"label":"A Label"}

Response:

[
  {
    "label": "A Label",
    "value": -29.765957771107,
    "_id": "532e5294c1f6d3f17df677ba"
  }
]

Example findOne API Query

Request: http://localhost:8080/api/v1/discreteBar/findOne?query={"label":"A Label"}

Response:

{
  "label": "A Label",
  "value": -29.765957771107,
  "_id": "532e5294c1f6d3f17df677ba"
}

Example aggretate API Query

Request: http://localhost:8080/api/v1/discreteBar/aggregate?pipeline=[{"$match":{"label":"A Label"}}]

Response:

[
  {
    "label": "A Label",
    "value": -29.765957771107,
    "_id": "532e5294c1f6d3f17df677ba"
  }
]