Skip to content

Commit 694d021

Browse files
committed
Merge branch 'master' into release
2 parents 59beed3 + 5c145b8 commit 694d021

File tree

4 files changed

+180
-102
lines changed

4 files changed

+180
-102
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
##### 3.0.0-rc.2 - 23 August 2016
2+
3+
###### Backwards compatible changes
4+
- Add support for `fields` option to `find` and `findAll`.
5+
16
##### 3.0.0-rc.1 - 15 August 2016
27

38
###### Backwards compatible changes

mocha.start.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,65 @@ describe('exports', function () {
7171
assert(JSDataRethinkDB.version)
7272
})
7373
})
74+
75+
describe('RethinkDBAdapter#find', function () {
76+
it('should allow subset of fields to be returned', function () {
77+
const User = this.$$User
78+
let props = { name: 'John', age: 30, role: 'admin', password: 'foo', address: { state: 'TX', zip: 12345 } }
79+
let user
80+
assert.debug('create', User.name, props)
81+
return this.$$adapter.create(User, props)
82+
.then((_user) => {
83+
user = _user
84+
85+
return this.$$adapter.find(User, user[User.idAttribute], { fields: User.idAttribute })
86+
})
87+
.then((_user) => {
88+
assert.objectsEqual(_user, {
89+
[User.idAttribute]: user[User.idAttribute]
90+
}, 'only ID was selected')
91+
92+
return this.$$adapter.find(User, user[User.idAttribute], { fields: [User.idAttribute, 'age'] })
93+
})
94+
.then((_user) => {
95+
assert.objectsEqual(_user, {
96+
[User.idAttribute]: user[User.idAttribute],
97+
age: user.age
98+
}, 'only ID and age were selected')
99+
})
100+
})
101+
})
102+
103+
describe('RethinkDBAdapter#findAll', function () {
104+
it('should allow subset of fields to be returned', function () {
105+
const User = this.$$User
106+
let props = { name: 'John', age: 30, role: 'dev', password: 'foo', address: { state: 'TX', zip: 12345 } }
107+
let props2 = { name: 'Sally', age: 28, role: 'admin', password: 'bar', address: { state: 'MA', zip: 54321 } }
108+
let users
109+
assert.debug('create', User.name, [props, props2])
110+
return this.$$adapter.createMany(User, [props, props2])
111+
.then((_users) => {
112+
users = _users
113+
114+
return this.$$adapter.findAll(User, { orderBy: 'name' }, { fields: User.idAttribute })
115+
})
116+
.then((_users) => {
117+
assert.objectsEqual(_users, [{
118+
[User.idAttribute]: users[0][User.idAttribute]
119+
}, {
120+
[User.idAttribute]: users[1][User.idAttribute]
121+
}], 'only ID was selected')
122+
123+
return this.$$adapter.findAll(User, { orderBy: 'name' }, { fields: [User.idAttribute, 'age'] })
124+
})
125+
.then((_users) => {
126+
assert.objectsEqual(_users, [{
127+
[User.idAttribute]: users[0][User.idAttribute],
128+
age: users[0].age
129+
}, {
130+
[User.idAttribute]: users[1][User.idAttribute],
131+
age: users[1].age
132+
}], 'only ID and age were selected')
133+
})
134+
})
135+
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-data-rethinkdb",
33
"description": "RethinkDB adapter for js-data.",
4-
"version": "3.0.0-rc.1",
4+
"version": "3.0.0-rc.2",
55
"homepage": "https://github.com/js-data/js-data-rethinkdb",
66
"repository": {
77
"type": "git",

0 commit comments

Comments
 (0)