1
1
/**
2
2
* @author Jason Dobry <[email protected] >
3
3
* @file angular-data.js
4
- * @version 0.9.0 - Homepage <http://angular-data.codetrain.io/>
4
+ * @version 0.9.1 - Homepage <http://angular-data.codetrain.io/>
5
5
* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/>
6
6
* @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>
7
7
*
@@ -1570,7 +1570,9 @@ function DSHttpAdapterProvider() {
1570
1570
options = options || { } ;
1571
1571
options . params = options . params || { } ;
1572
1572
if ( params ) {
1573
- params . query = params . query ? defaults . queryTransform ( resourceConfig . name , params . query ) : params . query ;
1573
+ if ( params . query ) {
1574
+ params . query = defaults . queryTransform ( resourceConfig . name , params . query ) ;
1575
+ }
1574
1576
DSUtils . deepMixIn ( options . params , params ) ;
1575
1577
}
1576
1578
return this . DEL (
@@ -1591,7 +1593,9 @@ function DSHttpAdapterProvider() {
1591
1593
options = options || { } ;
1592
1594
options . params = options . params || { } ;
1593
1595
if ( params ) {
1594
- params . query = params . query ? defaults . queryTransform ( resourceConfig . name , params . query ) : params . query ;
1596
+ if ( params . query ) {
1597
+ params . query = defaults . queryTransform ( resourceConfig . name , params . query ) ;
1598
+ }
1595
1599
DSUtils . deepMixIn ( options . params , params ) ;
1596
1600
}
1597
1601
return this . GET (
@@ -1613,7 +1617,9 @@ function DSHttpAdapterProvider() {
1613
1617
options = options || { } ;
1614
1618
options . params = options . params || { } ;
1615
1619
if ( params ) {
1616
- params . query = params . query ? defaults . queryTransform ( resourceConfig . name , params . query ) : params . query ;
1620
+ if ( params . query ) {
1621
+ params . query = defaults . queryTransform ( resourceConfig . name , params . query ) ;
1622
+ }
1617
1623
DSUtils . deepMixIn ( options . params , params ) ;
1618
1624
}
1619
1625
return this . PUT (
@@ -2302,7 +2308,7 @@ function _findAll(utils, resourceName, params, options) {
2302
2308
* ```
2303
2309
*
2304
2310
* @param {string } resourceName The resource type, e.g. 'user', 'comment', etc.
2305
- * @param {object } params Parameter object that is serialized into the query string. Properties:
2311
+ * @param {object= } params Parameter object that is serialized into the query string. Properties:
2306
2312
*
2307
2313
* - `{object=}` - `query` - The query object by which to filter items of the type specified by `resourceName`. Properties:
2308
2314
* - `{object=}` - `where` - Where clause.
@@ -2332,6 +2338,7 @@ function findAll(resourceName, params, options) {
2332
2338
_this = this ;
2333
2339
2334
2340
options = options || { } ;
2341
+ params = params || { } ;
2335
2342
2336
2343
if ( ! this . definitions [ resourceName ] ) {
2337
2344
deferred . reject ( new this . errors . RuntimeError ( errorPrefix + resourceName + ' is not a registered resource!' ) ) ;
@@ -4048,7 +4055,7 @@ var errorPrefix = 'DS.filter(resourceName, params[, options]): ';
4048
4055
* - `{UnhandledError}`
4049
4056
*
4050
4057
* @param {string } resourceName The resource type, e.g. 'user', 'comment', etc.
4051
- * @param {object } params Parameter object that is serialized into the query string. Properties:
4058
+ * @param {object= } params Parameter object that is serialized into the query string. Properties:
4052
4059
*
4053
4060
* - `{object=}` - `query` - The query object by which to filter items of the type specified by `resourceName`. Properties:
4054
4061
* - `{object=}` - `where` - Where clause.
@@ -4065,7 +4072,7 @@ function filter(resourceName, params, options) {
4065
4072
4066
4073
if ( ! this . definitions [ resourceName ] ) {
4067
4074
throw new this . errors . RuntimeError ( errorPrefix + resourceName + ' is not a registered resource!' ) ;
4068
- } else if ( ! this . utils . isObject ( params ) ) {
4075
+ } else if ( params && ! this . utils . isObject ( params ) ) {
4069
4076
throw new this . errors . IllegalArgumentError ( errorPrefix + 'params: Must be an object!' , { params : { actual : typeof params , expected : 'object' } } ) ;
4070
4077
} else if ( ! this . utils . isObject ( options ) ) {
4071
4078
throw new this . errors . IllegalArgumentError ( errorPrefix + 'options: Must be an object!' , { options : { actual : typeof options , expected : 'object' } } ) ;
@@ -4077,7 +4084,7 @@ function filter(resourceName, params, options) {
4077
4084
_this = this ;
4078
4085
4079
4086
// Protect against null
4080
- params . query = params . query || { } ;
4087
+ params = params || { } ;
4081
4088
4082
4089
var queryHash = this . utils . toJson ( params ) ;
4083
4090
@@ -4090,6 +4097,7 @@ function filter(resourceName, params, options) {
4090
4097
}
4091
4098
}
4092
4099
4100
+ params . query = params . query || { } ;
4093
4101
// The query has been completed, so hit the cache with the query
4094
4102
var filtered = this . utils . filter ( resource . collection , function ( attrs ) {
4095
4103
var keep = true ,
0 commit comments