8000 8.0.0 · js-data/js-data-adapter@394bbd9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 394bbd9

Browse files
committed
8.0.0
1 parent e4d335f commit 394bbd9

File tree

8 files changed

+67
-22
lines changed

8 files changed

+67
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ coverage
55
doc
66
dist/*.js
77
dist/*.map
8+
*.log

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Jason Dobry <jason.dobry@gmail.com> Jason Dobry <jmdobry@users.noreply.github.com>

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
# The email address is not required for organizations.
88
#
99
Jason Dobry <jason.dobry@gmail.com>
10+
Nick Escallon <nickescallon@gmail.com>

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
##### 0.8.0 - 10 August 2016
2+
3+
###### Breaking changes
4+
- Requiring latest rc of js-data
5+
6+
###### Backwards compatible changes
7+
- Updated dependencies
8+
9+
###### Bug fixes
10+
- #4, #5 response metadata not getting passed to findAll by @nickescallon
11+
112
##### 0.7.4 - 07 July 2016
213

314
###### Backwards compatible changes

CONTRIBUTORS

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# People who have contributed to the js-data-adapter project.
1+
# This is the official list of js-data-adapter project contributors.
22
#
3-
# Names should be added to this file as:
4-
# [commit count] Name <email address>
5-
1 Jason Dobry <jason.dobry@gmail.com>
3+
# Names are formatted as:
4+
# Name [email address]
5+
#
6+
Jason Dobry <jason.dobry@gmail.com>
7+
Nick Escallon <nickescallon@gmail.com>

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-data-adapter",
33
"description": "Base adapter class that all other js-data adapters extend.",
4-
"version": "0.7.4",
4+
"version": "0.8.0",
55
"homepage": "https://github.com/js-data/js-data-adapter",
66
"repository": {
77
"type": "git",
@@ -64,17 +64,17 @@
6464
"release": "npm test && repo-tools updates && repo-tools changelog && repo-tools authors"
6565
},
6666
"peerDependencies": {
67-
"js-data": "^3.0.0-beta.10"
67+
"js-data": "^3.0.0-rc.4"
6868
},
6969
"dependencies": {
7070
"chai": "^3.5.0",
71-
"mocha": "^2.5.3",
72-
"sinon": "^1.17.4"
71+
"mocha": "^3.0.2",
72+
"sinon": "^1.17.5"
7373
},
7474
"devDependencies": {
75-
"babel-plugin-syntax-async-functions": "6.8.0",
76-
"babel-plugin-transform-regenerator": "6.9.0",
75+
"babel-plugin-syntax-async-functions": "6.13.0",
76+
"babel-plugin-transform-regenerator": "6.11.4",
7777
"babel-preset-stage-0": "6.5.0",
78-
"js-data-repo-tools": "0.5.5"
78+
"js-data-repo-tools": "0.5.6"
7979
}
8080
}

test/findAll.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ export default function (options) {
3636
assert.equal(users2[0].name, 'John', users2[0].name)
3737
})
3838

39+
it('should filter users with raw option', async function () {
40+
let props = { name: 'John' }
41+
assert.debug('findAll', User.name, { age: 30 })
42+
const result = await adapter.findAll(User, { age: 30 }, { raw: true })
43+
const users = result.data
44+
assert.debug('found', User.name, users)
45+
assert.equal(result.mock, true, 'should have metadata')
46+
assert.equal(users.length, 0, 'users.length')
47+
48+
assert.debug('create', User.name, props)
49+
const user = await adapter.create(User, props)
50+
assert.debug('created', User.name, user)
51+
const userId = user[User.idAttribute]
52+
53+
assert.debug('findAll', User.name, { name: 'John' })
54+
const result2 = await adapter.findAll(User, { name: 'John' }, { raw: true })
55+
const users2 = result2.data
56+
assert.equal(result2.mock, true, 'should have metadata')
57+
assert.debug('found', User.name, users2)
58+
59+
assert.equal(users2.length, 1, 'users2.length')
60+
assert.equal(users2[0][User.idAttribute], userId, 'users2[0][User.idAttribute]')
61+
assert.equal(users2[0].name, 'John', users2[0].name)
62+
})
63+
3964
if (options.hasFeature('findAllInOp')) {
4065
it('should filter users using the "in" operator', async function () {
4166
var users = await adapter.findAll(User, {

test/mockAdapter.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ function getCollection (mapper) {
4545
return collection
4646
}
4747

48+
function makeResult () {
49+
return { mock: true }
50+
}
51+
4852
addHiddenPropsToTarget(MockAdapter.prototype, {
4953
_count: function (mapper, query) {
5054
var collection = getCollection(mapper)
5155
var records = collection.filter(query || {})
52-
return [records.length, {}]
56+
return [records.length, makeResult()]
5357
},
5458
_create: function (mapper, props) {
5559
props = plainCopy(props)
@@ -58,7 +62,7 @@ addHiddenPropsToTarget(MockAdapter.prototype, {
5862
}
5963
var created = JSON.parse(JSON.stringify(props))
6064
getCollection(mapper).add(created)
61-
return [created, {}]
65+
return [created, makeResult()]
6266
},
6367
_createMany: function (mapper, props) {
6468
props = plainCopy(props)
@@ -70,25 +74,25 @@ addHiddenPropsToTarget(MockAdapter.prototype, {
7074
created.push(JSON.parse(JSON.stringify(_props)))
7175
})
7276
getCollection(mapper).add(created)
73-
return [created, {}]
77+
return [created, makeResult()]
7478
},
7579
_destroy: function (mapper, id) {
7680
getCollection(mapper).remove(id)
77-
return [undefined, {}]
81+
return [undefined, makeResult()]
7882
},
7983
_destroyAll: function (mapper, query) {
8084
var collection = getCollection(mapper)
8185
var records = collection.filter(query || {})
8286
records.forEach(function (record) {
8387
collection.remove(record[mapper.idAttribute])
8488
})
85-
return [undefined, {}]
89+
return [undefined, makeResult()]
8690
},
8791
_find: function (mapper, id) {
88-
return [getCollection(mapper).get(id), {}]
92+
return [getCollection(mapper).get(id), makeResult()]
8993
},
9094
_findAll: function (mapper, query) {
91-
return [getCollection(mapper).filter(query || {}), {}]
95+
return [getCollection(mapper).filter(query || {}), makeResult()]
9296
},
9397
_sum: function (mapper, field, query) {
9498
var collection = getCollection(mapper)
@@ -98,7 +102,7 @@ addHiddenPropsToTarget(MockAdapter.prototype, {
98102
sum += record[field] || 0
99103
})
100104

101-
return [sum, {}]
105+
return [sum, makeResult()]
102106
},
103107
_update: function (mapper, id, props) {
104108
props = plainCopy(props)
@@ -108,22 +112,22 @@ addHiddenPropsToTarget(MockAdapter.prototype, {
108112
} else {
109113
throw new Error('Not Found')
110114
}
111-
return [record, {}]
115+
return [record, makeResult()]
112116
},
113117
_updateAll: function (mapper, props, query) {
114118
props = plainCopy(props)
115119
var records = getCollection(mapper).filter(query || {})
116120
records.forEach(function (record) {
117121
deepMixIn(record, props || {})
118122
})
119-
return [records, {}]
123+
return [records, makeResult()]
120124
},
121125
_updateMany: function (mapper, records) {
122126
var collection = getCollection(mapper)
123127
records || (records = [])
124128
records.forEach(function (record, i) {
125129
records[i] = collection.add(record)
126130
})
127-
return [records, {}]
131+
return [records, makeResult()]
128132
}
129133
})

0 commit comments

Comments
 (0)
0