-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepl.js
More file actions
44 lines (36 loc) Β· 1.23 KB
/
Copy pathrepl.js
File metadata and controls
44 lines (36 loc) Β· 1.23 KB
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
/* eslint-disable no-console */
const repl = require("repl");
const mongoose = require('mongoose');
const path = require('path');
const dotenv = require('dotenv');
const HikingTrail = require('./models/HikingTrail');
const Activity = require('./models/Activity');
const BikePath = require('./models/BikePath');
const Attraction = require('./model/Attraction');
const FoodJoint = require('./models/FoodJoint');
dotenv.config({
path: path.join(__dirname, '.env')
});
mongoose.connect(process.env.DATABASE, {
useNewUrlParser: true
});
const db = mongoose.connection;
db.on('error', (error) => {
console.error(`π
β π« π
β π« π
β‘ ${error.message} `);
});
db.once('open', function () {
const replServer = repl.start({
prompt: "my-app > ",
});
replServer.context.mongoose = mongoose;
replServer.context.foo = 'bar';
replServer.context.HikingTrail = HikingTrail;
replServer.context.FoodJoint = FoodJoint;
replServer.context.Attraction = Attraction;
replServer.context.Activity = Activity;
replServer.context.BikePath = BikePath;
});
// Ex: using Mongoose to query the database
// HikingTrail.where('distanceKM').gte(4).exec(function (err, result) {
// console.log(result)
// });