Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
78 lines (69 loc) · 2.3 KB

File metadata and controls

78 lines (69 loc) · 2.3 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
module.exports = function(app, logger, express, db) {
logger.info('module db');
var router = express.Router();
router.get('/list', function(req, res) {
// Use the admin database for the operation
db.collectionNames(function(err, docs) {
if (!err) {
var namelist = []
var reg = /db.([^\.].*)/g;
var match;
logger.debug("db:" + docs);
for (i in docs) {
match = reg.exec(docs[i].name)
if (match != null) {
logger.debug("document name:" + match[1]);
namelist.push(match[1]);
}
}
res.json(namelist);
}
})
});
router.get('/list/:doc', function(req, res) {
var doc = req.params.doc;
var collection = db.collection(doc);
collection.find({}).toArray(function(err, docs) {
logger.debug("Found the following records");
//console.dir(docs);
res.json(docs);
});
});
router.post('/add/:doc', function(req, res) {
var doc = req.params.doc;
var collection = db.collection(doc);
collection.insert(req.body);
res.json({
message: 'insert ok'
});
});
router.post('/update/:doc', function(req, res) {
var doc = req.params.doc;
var collection = db.collection(doc);
collection.update(req.body.query, req.body.command);
res.json({
message: 'update ok'
});
});
router.post('/query/:doc', function(req, res) {
var doc = req.params.doc;
var collection = db.collection(doc);
collection.find(req.body).toArray(function(err, docs) {
logger.debug("Found the following records");
//console.dir(docs);
res.json(docs);
});
});
router.delete('/remove/:doc', function(req, res) {
var doc = req.params.doc;
var collection = db.collection(doc);
collection.remove(req.body, function(err, result) {
logger.debug("Removed the document");
res.json({
message: 'remove ok',
result: result
});
});
});
app.use('/db', router);
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.