-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (25 loc) · 795 Bytes
/
index.js
File metadata and controls
31 lines (25 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// mongo ds031613.mongolab.com:31613/inventory -u netcse -p number1sakibkhan
var mongo = require('mongodb');
var express = require('express');
var monk = require('monk');
// var db = monk('localhost:27017');
var db = monk('mongodb://netcse:number1sakibkhan@ds31613.mongolab.com:31613/inventory');
var app = new express();
app.use(express.static(__dirname + '/public'));
app.get('/',function(req,res){
db.driver.admin.listDatabases(function(e,dbs){
res.json(dbs);
});
});
app.get('/collections',function(req,res){
db.driver.collectionNames(function(e,names){
res.json(names);
})
});
app.get('/collections/:name',function(req,res){
var collection = db.get(req.params.name);
collection.find({},{limit:200},function(e,docs){
res.json(docs);
})
});
app.listen(3000)