Skip to content

Commit

Permalink
1.0.0-alpha.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Feb 28, 2016
1 parent 65fbd15 commit 1d4c329
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 33 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
##### 1.0.0-alpha.2 - 27 February 2016

###### Backwards compatible bug fixes
- Fixed use of options

##### 1.0.0-alpha.1 - 26 February 2016

###### Breaking API changes
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
#
# Names should be added to this file as:
# [commit count] Name <email address>
24 Jason Dobry <jason.dobry@gmail.com>
26 Jason Dobry <jason.dobry@gmail.com>
1 John Grogg <johng@freshrealm.co>
31 changes: 16 additions & 15 deletions dist/js-data-mongodb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js-data-mongodb.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "js-data-mongodb",
"description": "MongoDB adapter for js-data.",
"version": "1.0.0-alpha.1",
"version": "1.0.0-alpha.2",
"homepage": "https://github.com/js-data/js-data-mongodb",
"repository": {
"type": "git",
Expand Down
31 changes: 16 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
isObject,
isString,
isUndefined,
plainCopy,
resolve
} = utils

Expand Down Expand Up @@ -387,20 +388,20 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
* @method
* @return {Object}
*/
getQuery (Resource, query) {
query || (query = {})
getQuery (mapper, query) {
query = plainCopy(query || {})
query.where || (query.where = {})

forOwn(query, function (v, k) {
if (reserved.indexOf(k) === -1) {
if (isObject(v)) {
query.where[k] = v
forOwn(query, function (config, keyword) {
if (reserved.indexOf(keyword) === -1) {
if (isObject(config)) {
query.where[keyword] = config
} else {
query.where[k] = {
'==': v
query.where[keyword] = {
'==': config
}
}
delete query[k]
delete query[keyword]
}
})

Expand Down Expand Up @@ -534,8 +535,8 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
* @method
* @return {Object}
*/
getQueryOptions (Resource, query) {
query = query || {}
getQueryOptions (mapper, query) {
query = plainCopy(query || {})
query.orderBy = query.orderBy || query.sort
query.skip = query.skip || query.offset

Expand Down Expand Up @@ -578,7 +579,7 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
*/
getOpt (opt, opts) {
opts || (opts = {})
return isUndefined(opts[opt]) ? this[opt] : opts[opt]
return isUndefined(opts[opt]) ? plainCopy(this[opt]) : plainCopy(opts[opt])
},

/**
Expand All @@ -588,8 +589,8 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
* @method
* @return {*}
*/
toObjectID (Resource, id) {
if (id !== undefined && Resource.idAttribute === '_id' && typeof id === 'string' && ObjectID.isValid(id) && !(id instanceof ObjectID)) {
toObjectID (mapper, id) {
if (id !== undefined && mapper.idAttribute === '_id' && typeof id === 'string' && ObjectID.isValid(id) && !(id instanceof ObjectID)) {
return new ObjectID(id)
}
return id
Expand Down Expand Up @@ -1062,7 +1063,7 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
*
* @name MongoDBAdapter#destroy
* @method
* @param {Object} Resource The Resource.
* @param {Object} mapper The mapper.
* @param {(string|number)} id Primary key of the record to destroy.
* @param {Object} [opts] Configuration options.
* @param {boolean} [opts.raw=false] Whether to return a more detailed
Expand Down

0 comments on commit 1d4c329

Please sign in to comment.