Skip to content

Commit 0b2c554

Browse files
committed
Stable Version 0.1.0.
1 parent 5c6971b commit 0b2c554

12 files changed

+691
-26
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ node_modules
2929

3030
.idea/
3131
*.iml
32+
33+
data/

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
##### 0.1.0 - 18 February 2015
2+
3+
- Initial Release
4+
15
##### 0.0.1 - 05 February 2015
26

37
- Initial Commit

Diff for: Gruntfile.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* js-data-mongodb
3+
* http://github.com/js-data/js-data-mongodb
4+
*
5+
* Copyright (c) 2014 Jason Dobry <http://www.js-data.io/js-data-mongodb>
6+
* Licensed under the MIT license. <https://github.com/js-data/js-data-mongodb/blob/master/LICENSE>
7+
*/
8+
module.exports = function (grunt) {
9+
'use strict';
10+
11+
require('jit-grunt')(grunt, {
12+
coveralls: 'grunt-karma-coveralls'
13+
});
14+
require('time-grunt')(grunt);
15+
16+
var pkg = grunt.file.readJSON('package.json');
17+
18+
// Project configuration.
19+
grunt.initConfig({
20+
pkg: pkg,
21+
jshint: {
22+
all: ['Gruntfile.js', 'src/**/*.js', 'test/*.js'],
23+
jshintrc: '.jshintrc'
24+
},
25+
watch: {
26+
dist: {
27+
files: ['src/**/*.js'],
28+
tasks: ['build']
29+
}
30+
},
31+
coveralls: {
32+
options: {
33+
coverage_dir: 'coverage'
34+
}
35+
},
36+
mochaTest: {
37+
all: {
38+
options: {
39+
timeout: 20000,
40+
reporter: 'spec'
41+
},
42+
src: ['mocha.start.js', 'test/**/*.js']
43+
}
44+
}
45+
});
46+
47+
grunt.registerTask('n', ['mochaTest']);
48+
49+
grunt.registerTask('test', ['build', 'n']);
50+
grunt.registerTask('build', [
51+
'jshint'
52+
]);
53+
grunt.registerTask('go', ['build', 'watch:dist']);
54+
grunt.registerTask('default', ['build']);
55+
};

Diff for: README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@ var DSMongoDBAdapter = require('js-data-mongodb');
2727
var store = new JSData.DS();
2828
var adapter = new DSMongoDBAdapter();
2929

30+
// "store" will now use the MongoDB adapter for all async operations
3031
store.registerAdapter('mongodb', adapter, { default: true });
3132

32-
// "store" will now use the MongoDB adapter for all async operations
33+
var User = store.defineResource({
34+
// Why couldn't Mongo just use "id"?
35+
idAttribute: '_id',
36+
37+
// map this resource to a collection, default is Resource#name
38+
table: 'users'
39+
});
3340
```
3441

3542
## Changelog

Diff for: mocha.start.js

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*global assert:true */
2+
'use strict';
3+
4+
var assert = require('chai').assert;
5+
var mocha = require('mocha');
6+
var sinon = require('sinon');
7+
var DSMongoDBAdapter = require('./');
8+
var JSData = require('js-data');
9+
10+
var adapter, store, DSUtils, DSErrors, User, Post, Comment;
11+
12+
var globals = module.exports = {
13+
fail: function (msg) {
14+
assert.equal('should not reach this!: ' + msg, 'failure');
15+
},
16+
TYPES_EXCEPT_STRING: [123, 123.123, null, undefined, {}, [], true, false, function () {
17+
}],
18+
TYPES_EXCEPT_STRING_OR_ARRAY: [123, 123.123, null, undefined, {}, true, false, function () {
19+
}],
20+
TYPES_EXCEPT_STRING_OR_NUMBER: [null, undefined, {}, [], true, false, function () {
21+
}],
22+
TYPES_EXCEPT_STRING_OR_OBJECT: [123, 123.123, null, undefined, [], true, false, function () {
23+
}],
24+
TYPES_EXCEPT_STRING_OR_NUMBER_OBJECT: [null, undefined, [], true, false, function () {
25+
}],
26+
TYPES_EXCEPT_STRING_OR_ARRAY_OR_NUMBER: [null, undefined, {}, true, false, function () {
27+
}],
28+
TYPES_EXCEPT_NUMBER: ['string', null, undefined, {}, [], true, false, function () {
29+
}],
30+
TYPES_EXCEPT_OBJECT: ['string', 123, 123.123, null, undefined, true, false, function () {
31+
}],
32+
TYPES_EXCEPT_BOOLEAN: ['string', 123, 123.123, null, undefined, {}, [], function () {
33+
}],
34+
TYPES_EXCEPT_FUNCTION: ['string', 123, 123.123, null, undefined, {}, [], true, false],
35+
assert: assert,
36+
sinon: sinon,
37+
adapter: undefined
38+
};
39+
40+
var test = new mocha();
41+
42+
var testGlobals = [];
43+
44+
for (var key in globals) {
45+
global[key] = globals[key];
46+
testGlobals.push(globals[key]);
47+
}
48+
test.globals(testGlobals);
49+
50+
beforeEach(function () {
51+
store = new JSData.DS();
52+
adapter = new DSMongoDBAdapter('mongodb://localhost:27017');
53+
DSUtils = JSData.DSUtils;
54+
DSErrors = JSData.DSErrors;
55+
globals.User = global.User = User = store.defineResource({
56+
name: 'user',
57+
idAttribute: '_id',
58+
relations: {
59+
hasMany: {
60+
post: {
61+
localField: 'posts',
62+
foreignKey: 'post'
63+
}
64+
}
65+
}
66+
});
67+
globals.Post = global.Post = Post = store.defineResource({
68+
name: 'post',
69+
idAttribute: '_id',
70+
relations: {
71+
belongsTo: {
72+
user: {
73+
localField: 'user',
74+
localKey: 'userId'
75+
}
76+
},
77+
hasMany: {
78+
comment: {
79+
localField: 'comments',
80+
foreignKey: 'postId'
81+
}
82+
}
83+
}
84+
});
85+
globals.Comment = global.Comment = Comment = store.defineResource({
86+
name: 'comment',
87+
idAttribute: '_id',
88+
relations: {
89+
belongsTo: {
90+
post: {
91+
localField: 'post',
92+
localKey: 'postId'
93+
},
94+
user: {
95+
localField: 'user',
96+
localKey: 'userId'
97+
}
98+
}
99+
}
100+
});
101+
102+
globals.adapter = adapter;
103+
global.adapter = globals.adapter;
104+
105+
globals.DSUtils = DSUtils;
106+
global.DSUtils = globals.DSUtils;
107+
108+
globals.DSErrors = DSErrors;
109+
global.DSErrors = globals.DSErrors;
110+
});
111+
112+
afterEach(function (done) {
113+
globals.adapter = null;
114+
global.adapter = null;
115+
116+
adapter.destroyAll(User, {}).then(function () {
117+
done();
118+
}, done);
119+
});

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-data-mongodb",
33
"description": "MongoDB adapter for js-data.",
4-
"version": "0.0.1",
4+
"version": "0.1.0",
55
"homepage": "http://www.js-data.io/docs/dsmongodbadapter",
66
"repository": {
77
"type": "git",
@@ -32,7 +32,7 @@
3232
"grunt-contrib-jshint": "0.11.0",
3333
"grunt-contrib-watch": "0.6.1",
3434
"grunt-karma-coveralls": "2.5.3",
35-
"grunt-mocha-test": "0.12.6",
35+
"grunt-mocha-test": "0.12.7",
3636
"jit-grunt": "0.9.1",
3737
"sinon": "1.12.2",
3838
"time-grunt": "1.0.0"

0 commit comments

Comments
 (0)