forked from vikingeducation/project_ponz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepl.js
More file actions
executable file
·25 lines (21 loc) · 697 Bytes
/
repl.js
File metadata and controls
executable file
·25 lines (21 loc) · 697 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
// Require mongoose and start up the REPL
// Also require our models
var mongoose = require("mongoose");
var repl = require("repl").start({});
var models = require("./models");
// Use our promise based connection
// file to wrap our REPL and execute
// only once we've connected to MongoDB
require("./mongo")().then(() => {
// Set `models` to be available in
// the REPL by name
repl.context.models = models;
// Set each model to be available in the REPL
// by name
Object.keys(models).forEach(modelName => {
repl.context[modelName] = mongoose.model(modelName);
});
// Helper function to output the result of
// a query
repl.context.lg = data => console.log(data);
});