File tree 5 files changed +17
-9
lines changed
5 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ var collection;
11
11
var TaskMdl ;
12
12
var Task ;
13
13
var Roller ;
14
- var utils ;
14
+ var dbUtils ;
15
15
16
16
var Fawn = {
17
17
init : function ( db , _collection , options ) {
@@ -41,7 +41,7 @@ var Fawn = {
41
41
TaskMdl = require ( "../models/task" ) ( mongoose , collection ) ;
42
42
Task = require ( "./task" ) ( mongoose , TaskMdl ) ;
43
43
Roller = require ( "./roller" ) ( mongoose , TaskMdl ) ;
44
- utils = require ( "./utils/db.utils" ) ( mongoose ) ;
44
+ dbUtils = require ( "./utils/db.utils" ) ( mongoose ) ;
45
45
}
46
46
47
47
, Task : function ( ) {
@@ -56,7 +56,7 @@ var Fawn = {
56
56
57
57
, initModel : function ( modelName , schema ) {
58
58
checkInitStatus ( ) ;
59
- utils . initModel ( modelName , schema ) ;
59
+ dbUtils . initModel ( modelName , schema ) ;
60
60
}
61
61
} ;
62
62
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ var TaskProvider = function (_mongoose, _TaskMdl) {
58
58
setModel = dbUtils . setModel ;
59
59
getModel = dbUtils . getModel ;
60
60
61
+ goose . setDbUtils ( dbUtils ) ;
62
+
61
63
return Task ;
62
64
} ;
63
65
Original file line number Diff line number Diff line change 4
4
*/
5
5
var constants = require ( "../constants" ) ;
6
6
var utils = require ( "../utils/gen.utils" ) ;
7
- var dbUtils = require ( "../utils/db.utils" ) ( ) ;
7
+ var dbUtils ;
8
8
9
- // utility functions
9
+ // gen utility functions
10
10
var resolveFuture = utils . resolveFuture ;
11
11
var storeOldData = utils . storeOldData ;
12
12
var updateState = utils . updateState ;
13
13
var xcode = utils . xcode ;
14
- var getModel = dbUtils . getModel ;
14
+
15
+ // db utility functions
16
+ var getModel ;
15
17
16
18
// constants
17
19
var PENDING = constants . PENDING ;
18
20
var DONE = constants . DONE ;
19
21
22
+ exports . setDbUtils = function ( _dbUtils ) {
23
+ dbUtils = _dbUtils ;
24
+ getModel = dbUtils . getModel ;
25
+ } ;
26
+
20
27
/**
21
28
* This function handles the update step using
22
29
* mongoose.
Original file line number Diff line number Diff line change @@ -11,8 +11,7 @@ var constants = require("../constants");
11
11
var mongoose ;
12
12
13
13
module . exports = function ( _mongoose ) {
14
- if ( ! mongoose ) mongoose = _mongoose || require ( "mongoose" ) ;
15
-
14
+ mongoose = _mongoose ;
16
15
var Schema = mongoose . Schema ;
17
16
18
17
/**
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ global.mongoose = require("mongoose");
18
18
global . Grid = require ( "gridfs-stream" ) ;
19
19
Grid . mongo = mongoose . mongo ;
20
20
21
- global . dbUtils = require ( "../lib/utils/db.utils" ) ( ) ;
21
+ global . dbUtils = require ( "../lib/utils/db.utils" ) ( mongoose ) ;
22
22
global . utils = require ( "../lib/utils/gen.utils" ) ;
23
23
global . expect = config . expect ;
24
24
global . Promise = config . Promise ;
You can’t perform that action at this time.
0 commit comments