How to instantiate compound environment in a jake file?
- Ngôn ngữ chính
- JavaScript
- Star
- 1.6k
- Fork
- 179
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Look at the compound.js file or the main application entry point to see how the compound environment is instantiated. Examine the db/schema.js file to understand how models are registered with mongoose and compound. The goal is to replicate that initialization in a jake file, likely requiring access to the compound instance or its configuration.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, node.js
- Lĩnh vực
- backend, cli
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100