File tree 9 files changed +33
-17
lines changed
9 files changed +33
-17
lines changed Original file line number Diff line number Diff line change 1
- Copyright (c) 2013 Fractal <contact@wearefractal.com>
1
+ Copyright (c) 2015 Fractal <contact@wearefractal.com>
2
2
3
3
Permission is hereby granted, free of charge, to any person obtaining
4
4
a copy of this software and associated documentation files (the
Original file line number Diff line number Diff line change 3
3
## Information
4
4
5
5
<table >
6
- <tr >
6
+ <tr >
7
7
<td >Package</td ><td >goosestrap</td >
8
8
</tr >
9
9
<tr >
@@ -40,7 +40,7 @@ var Movie = db.model('Movie');
40
40
41
41
(MIT License)
42
42
43
- Copyright (c) 2013 Fractal < contact@wearefractal.com >
43
+ Copyright (c) 2015 Fractal < contact@wearefractal.com >
44
44
45
45
Permission is hereby granted, free of charge, to any person obtaining
46
46
a copy of this software and associated documentation files (the
Original file line number Diff line number Diff line change
1
+ mongoose = require ' mongoose'
2
+ glob = require ' glob'
3
+ path = require ' path'
4
+
5
+ module .exports = (url , modelPath ) ->
6
+ db = mongoose .createConnection url
7
+ models = glob .sync modelPath
8
+ for model in models
9
+ name = path .basename model, path .extname model
10
+ schema = require model
11
+ db .model name, schema
12
+
13
+ return db
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " goosestrap" ,
3
3
"description" : " bootstrap your mongoose" ,
4
- "version" : " 0.0.5 " ,
4
+ "version" : " 0.0.4 " ,
5
5
"homepage" : " http://github.com/wearefractal/goosestrap" ,
6
6
"repository" : " git://github.com/wearefractal/goosestrap.git" ,
7
7
"author" : " Fractal <contact@wearefractal.com> (http://wearefractal.com/)" ,
8
8
"main" : " ./index.js" ,
9
9
"dependencies" : {
10
- "glob " : " ^4.0.2 " ,
11
- "require-dir " : " ^0.1.0 "
10
+ "require-dir " : " ^0.1.0 " ,
11
+ "glob " : " ^4.0.2 "
12
12
},
13
13
"peerDependencies" : {
14
14
"mongoose" : " ^3.8.11"
19
19
"should" : " ^4.0.0"
20
20
},
21
21
"scripts" : {
22
- "test" : " mocha --compilers coffee:coffee-script/register --ui exports"
22
+ "test" : " mocha --compilers coffee:coffee-script/register --ui exports --reporter spec "
23
23
},
24
24
"engines" : {
25
25
"node" : " >= 0.4.0"
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ goosestrap = require '../'
2
2
should = require ' should'
3
3
path = require ' path'
4
4
5
- module .exports =
5
+ module .exports =
6
6
7
7
" it should connect " : =>
8
8
@db = goosestrap " mongodb://localhost/goosestrap" , path .resolve ' ./test/models/*'
@@ -14,13 +14,16 @@ module.exports =
14
14
(typeof @db .model ' User' ).should .equal ' function'
15
15
(typeof @db .model ' Movie' ).should .equal ' function'
16
16
17
+ " it should load all object models " : =>
18
+ (typeof @db .models .User ).should .equal ' function'
19
+ (typeof @db .models .Movie ).should .equal ' function'
20
+
17
21
" it should support nested dir globbing " : =>
18
22
@db = goosestrap " mongodb://localhost/goosestrap" , path .resolve ' ./test/nested/**/models/*'
19
23
20
- " db should be an object " : =>
24
+ " db should be an object when nested " : =>
21
25
(typeof @db ).should .equal ' object'
22
26
23
- " it should load all models " : =>
24
- (typeof @db .model ' User' ).should .equal ' function'
25
- (typeof @db .model ' Movie' ).should .equal ' function'
26
-
27
+ " it should load all object models when nested " : =>
28
+ (typeof @db .models .User ).should .equal ' function'
29
+ (typeof @db .models .Movie ).should .equal ' function'
Original file line number Diff line number Diff line change @@ -14,4 +14,4 @@ Movie = new Schema
14
14
required : true
15
15
16
16
17
- module .exports = Movie
17
+ module .exports = Movie
Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ User = new Schema
11
11
required : true
12
12
13
13
14
- module .exports = User
14
+ module .exports = User
Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ User = new Schema
11
11
required : true
12
12
13
13
14
- module .exports = User
14
+ module .exports = User
Original file line number Diff line number Diff line change @@ -14,4 +14,4 @@ Movie = new Schema
14
14
required : true
15
15
16
16
17
- module .exports = Movie
17
+ module .exports = Movie
You can’t perform that action at this time.
0 commit comments