Skip to content

Commit 1d4c329

Browse files
committed
1.0.0-alpha.2
1 parent 65fbd15 commit 1d4c329

File tree

6 files changed

+40
-33
lines changed

6 files changed

+40
-33
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
##### 1.0.0-alpha.2 - 27 February 2016
2+
3+
###### Backwards compatible bug fixes
4+
- Fixed use of options
5+
16
##### 1.0.0-alpha.1 - 26 February 2016
27

38
###### Breaking API changes

CONTRIBUTORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
#
55
# Names should be added to this file as:
66
# [commit count] Name <email address>
7-
24 Jason Dobry <[email protected]>
7+
26 Jason Dobry <[email protected]>
88
1 John Grogg <[email protected]>

dist/js-data-mongodb.js

Lines changed: 16 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js-data-mongodb.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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-mongodb",
33
"description": "MongoDB adapter for js-data.",
4-
"version": "1.0.0-alpha.1",
4+
"version": "1.0.0-alpha.2",
55
"homepage": "https://github.com/js-data/js-data-mongodb",
66
"repository": {
77
"type": "git",

src/index.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const {
1313
isObject,
1414
isString,
1515
isUndefined,
16+
plainCopy,
1617
resolve
1718
} = utils
1819

@@ -387,20 +388,20 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
387388
* @method
388389
* @return {Object}
389390
*/
390-
getQuery (Resource, query) {
391-
query || (query = {})
391+
getQuery (mapper, query) {
392+
query = plainCopy(query || {})
392393
query.where || (query.where = {})
393394

394-
forOwn(query, function (v, k) {
395-
if (reserved.indexOf(k) === -1) {
396-
if (isObject(v)) {
397-
query.where[k] = v
395+
forOwn(query, function (config, keyword) {
396+
if (reserved.indexOf(keyword) === -1) {
397+
if (isObject(config)) {
398+
query.where[keyword] = config
398399
} else {
399-
query.where[k] = {
400-
'==': v
400+
query.where[keyword] = {
401+
'==': config
401402
}
402403
}
403-
delete query[k]
404+
delete query[keyword]
404405
}
405406
})
406407

@@ -534,8 +535,8 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
534535
* @method
535536
* @return {Object}
536537
*/
537-
getQueryOptions (Resource, query) {
538-
query = query || {}
538+
getQueryOptions (mapper, query) {
539+
query = plainCopy(query || {})
539540
query.orderBy = query.orderBy || query.sort
540541
query.skip = query.skip || query.offset
541542

@@ -578,7 +579,7 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
578579
*/
579580
getOpt (opt, opts) {
580581
opts || (opts = {})
581-
return isUndefined(opts[opt]) ? this[opt] : opts[opt]
582+
return isUndefined(opts[opt]) ? plainCopy(this[opt]) : plainCopy(opts[opt])
582583
},
583584

584585
/**
@@ -588,8 +589,8 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
588589
* @method
589590
* @return {*}
590591
*/
591-
toObjectID (Resource, id) {
592-
if (id !== undefined && Resource.idAttribute === '_id' && typeof id === 'string' && ObjectID.isValid(id) && !(id instanceof ObjectID)) {
592+
toObjectID (mapper, id) {
593+
if (id !== undefined && mapper.idAttribute === '_id' && typeof id === 'string' && ObjectID.isValid(id) && !(id instanceof ObjectID)) {
593594
return new ObjectID(id)
594595
}
595596
return id
@@ -1062,7 +1063,7 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
10621063
*
10631064
* @name MongoDBAdapter#destroy
10641065
* @method
1065-
* @param {Object} Resource The Resource.
1066+
* @param {Object} mapper The mapper.
10661067
* @param {(string|number)} id Primary key of the record to destroy.
10671068
* @param {Object} [opts] Configuration options.
10681069
* @param {boolean} [opts.raw=false] Whether to return a more detailed

0 commit comments

Comments
 (0)