This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
module.exports = () => { | |
// Get all collections | |
let collections = mongoose | |
.connection | |
.collections; | |
// Get collection names |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const models = require('../models'); | |
Object.keys(models).forEach((modelName) => { | |
global[modelName] = mongoose.model(modelName); | |
}); | |
require('../mongo')() | |
.then(() => console.log('Cleaning Database...')) | |
.then(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var repl = require('repl').start({}); | |
var models = require('./models'); | |
require('./mongo')().then(() => { | |
repl.context.models = models; | |
Object.keys(models).forEach((modelName) => { | |
repl.context[modelName] = mongoose.model(modelName); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require("mongoose"); | |
const env = process.env.NODE_ENV || "development"; | |
const config = require("./config/mongo")[env]; | |
module.exports = () => { | |
const envUrl = process.env[config.use_env_variable]; | |
const localUrl = `mongodb://${config.host}/${config.database}`; | |
const mongoUrl = envUrl ? envUrl : localUrl; | |
return mongoose.connect(mongoUrl); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const express = require('express'); | |
const basename = path.basename(__filename); | |
const Helpers = {}; | |
// Object to hold registered helpers | |
Helpers.registered = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Require the REPL module | |
// and models | |
let repl = require('repl').start({}); | |
const models = require('./models'); | |
// Make the `models` object | |
// a global variable in the | |
// REPL | |
repl.context.models = models; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
// ---------------------------------------- | |
// Dotenv | |
// ---------------------------------------- | |
if (process.env.NODE_ENV !== "production") { | |
require("dotenv").config(); | |
} |