1602 / 1602/compound

How to instantiate compound environment in a jake file?

Open
#604 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.6k
Forks
179
PR merge metrics
No merged PRs in 30d

Description

I am trying to use a jake file to run a custom task to do some actions with Models.

Below is the code i use to initialize the Models used in the application in a jake file.

```
var conf = require('../config/database.json')[process.env.NODE_ENV || 'development'];
var mongoose = require('mongoose');
var db = mongoose.connect(conf.url);
```

This code is working to establish a connection, but i could not import all the Models i have defined in db/schema.js file as like i did in mongooose.js file

```
exports.init = function (compound) {
var conf = require('./database.json')[compound.app.set('env')];
var mongoose = require('mongoose');
mongoose.connect(conf.url);
require(compound.root + '/db/schema')(mongoose, compound);
};
```

since i don't have any reference to `compound` in jake file, i could not initialize all the models in the jake file and i have to redefine all the models in shcema.js files in jake file.

Please suggest.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.