1+ /**
2+ * @author Jason Dobry <jason.dobry@gmail.com>
3+ * @file angular-data.js
4+ * @version 0.5.0 - Homepage <http://jmdobry.github.io/angular-data/>
5+ * @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/angular-data>
6+ * @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>
7+ *
8+ * @overview Data store for Angular.js.
9+ */
110require = ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; throw new Error ( "Cannot find module '" + o + "'" ) } var f = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( f . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , f , f . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( require , module , exports ) {
211var indexOf = require ( './indexOf' ) ;
312
@@ -1953,7 +1962,6 @@ module.exports = destroy;
19531962var utils = require ( 'utils' ) ,
19541963 errors = require ( 'errors' ) ,
19551964 services = require ( 'services' ) ,
1956- GET = require ( '../../http' ) . GET ,
19571965 errorPrefix = 'DS.find(resourceName, id[, options]): ' ;
19581966
19591967/**
@@ -2023,7 +2031,7 @@ function find(resourceName, id, options) {
20232031
20242032 if ( ! ( id in resource . completedQueries ) ) {
20252033 if ( ! ( id in resource . pendingQueries ) ) {
2026- promise = resource . pendingQueries [ id ] = GET ( utils . makePath ( resource . baseUrl , resource . endpoint , id ) , null )
2034+ promise = resource . pendingQueries [ id ] = _this . GET ( utils . makePath ( resource . baseUrl , resource . endpoint , id ) , null )
20272035 . then ( function ( data ) {
20282036 // Query is no longer pending
20292037 delete resource . pendingQueries [ id ] ;
@@ -2046,11 +2054,10 @@ function find(resourceName, id, options) {
20462054
20472055module . exports = find ;
20482056
2049- } , { "../../http" : 34 , " errors" :"hIh4e1" , "services" :"cX8q+p" , "utils" :"uE/lJt" } ] , 30 :[ function ( require , module , exports ) {
2057+ } , { "errors" :"hIh4e1" , "services" :"cX8q+p" , "utils" :"uE/lJt" } ] , 30 :[ function ( require , module , exports ) {
20502058var utils = require ( 'utils' ) ,
20512059 errors = require ( 'errors' ) ,
20522060 services = require ( 'services' ) ,
2053- GET = require ( '../../http' ) . GET ,
20542061 errorPrefix = 'DS.findAll(resourceName, params[, options]): ' ;
20552062
20562063function processResults ( data , resourceName , queryHash ) {
@@ -2068,7 +2075,7 @@ function processResults(data, resourceName, queryHash) {
20682075 }
20692076
20702077 // Update the data store's index for this resource
2071- resource . index = utils . toLookup ( resource . collection , resource . idAttribute || services . config . idAttribute || 'id' ) ;
2078+ resource . index = utils . toLookup ( resource . collection , resource . idAttribute ) ;
20722079
20732080 // Update modified timestamp of collection
20742081 resource . collectionModified = utils . updateTimestamp ( resource . collectionModified ) ;
@@ -2090,7 +2097,7 @@ function _findAll(resourceName, params, options) {
20902097 if ( ! ( queryHash in resource . pendingQueries ) ) {
20912098
20922099 // This particular query has never even been made
2093- resource . pendingQueries [ queryHash ] = GET ( utils . makePath ( resource . baseUrl , resource . endpoint ) , { params : params } )
2100+ resource . pendingQueries [ queryHash ] = _this . GET ( utils . makePath ( resource . baseUrl , resource . endpoint ) , { params : params } )
20942101 . then ( function ( data ) {
20952102 try {
20962103 return processResults . apply ( _this , [ data , resourceName , queryHash ] ) ;
@@ -2202,7 +2209,7 @@ function findAll(resourceName, params, options) {
22022209
22032210module . exports = findAll ;
22042211
2205- } , { "../../http" : 34 , " errors" :"hIh4e1" , "services" :"cX8q+p" , "utils" :"uE/lJt" } ] , 31 :[ function ( require , module , exports ) {
2212+ } , { "errors" :"hIh4e1" , "services" :"cX8q+p" , "utils" :"uE/lJt" } ] , 31 :[ function ( require , module , exports ) {
22062213module . exports = {
22072214 /**
22082215 * @doc method
@@ -2269,8 +2276,7 @@ module.exports = {
22692276var utils = require ( 'utils' ) ,
22702277 errors = require ( 'errors' ) ,
22712278 services = require ( 'services' ) ,
2272- PUT = require ( '../../http' ) . PUT ,
2273- errorPrefix = 'DS.refresh(resourceName, id): ' ;
2279+ errorPrefix = 'DS.refresh(resourceName, id[, options]): ' ;
22742280
22752281/**
22762282 * @doc method
@@ -2329,21 +2335,23 @@ function refresh(resourceName, id, options) {
23292335 if ( ! services . store [ resourceName ] ) {
23302336 throw new errors . RuntimeError ( errorPrefix + resourceName + ' is not a registered resource!' ) ;
23312337 } else if ( ! utils . isString ( id ) && ! utils . isNumber ( id ) ) {
2332- throw new errors . IllegalArgumentError ( 'DS.refresh(resourceName, id): id: Must be a string or a number!', { id : { actual : typeof id , expected : 'string|number' } } ) ;
2338+ throw new errors . IllegalArgumentError ( errorPrefix + ' id: Must be a string or a number!', { id : { actual : typeof id , expected : 'string|number' } } ) ;
23332339 } else if ( ! utils . isObject ( options ) ) {
23342340 throw new errors . IllegalArgumentError ( errorPrefix + 'options: Must be an object!' , { options : { actual : typeof options , expected : 'object' } } ) ;
2335- }
2336-
2337- if ( id in services . store [ resourceName ] . index ) {
2338- return this . find ( resourceName , id , true ) ;
23392341 } else {
2340- return false ;
2342+ options . bypassCache = true ;
2343+
2344+ if ( id in services . store [ resourceName ] . index ) {
2345+ return this . find ( resourceName , id , options ) ;
2346+ } else {
2347+ return false ;
2348+ }
23412349 }
23422350}
23432351
23442352module . exports = refresh ;
23452353
2346- } , { "../../http" : 34 , " errors" :"hIh4e1" , "services" :"cX8q+p" , "utils" :"uE/lJt" } ] , 33 :[ function ( require , module , exports ) {
2354+ } , { "errors" :"hIh4e1" , "services" :"cX8q+p" , "utils" :"uE/lJt" } ] , 33 :[ function ( require , module , exports ) {
23472355var utils = require ( 'utils' ) ,
23482356 errors = require ( 'errors' ) ,
23492357 services = require ( 'services' ) ,
@@ -2995,9 +3003,9 @@ Resource.prototype = services.config;
29953003 * idAttribute: '_id',
29963004 * endpoint: '/documents
29973005 * baseUrl: 'http://myapp.com/api',
2998- * validate : function (attrs, options , cb) {
3006+ * beforeDestroy : function (resourceName attrs , cb) {
29993007 * console.log('looks good to me');
3000- * cb(null);
3008+ * cb(null, attrs );
30013009 * }
30023010 * });
30033011 * ```
@@ -3926,7 +3934,9 @@ function previous(resourceName, id) {
39263934
39273935module . exports = previous ;
39283936
3929- } , { "errors" :"hIh4e1" , "services" :"cX8q+p" , "utils" :"uE/lJt" } ] , "hIh4e1" :[ function ( require , module , exports ) {
3937+ } , { "errors" :"hIh4e1" , "services" :"cX8q+p" , "utils" :"uE/lJt" } ] , "errors" :[ function ( require , module , exports ) {
3938+ module . exports = require ( 'hIh4e1' ) ;
3939+ } , { } ] , "hIh4e1" :[ function ( require , module , exports ) {
39303940/**
39313941 * @doc function
39323942 * @id errors.types:UnhandledError
@@ -4138,8 +4148,6 @@ module.exports = {
41384148 RuntimeError : RuntimeError
41394149} ;
41404150
4141- } , { } ] , "errors" :[ function ( require , module , exports ) {
4142- module . exports = require ( 'hIh4e1' ) ;
41434151} , { } ] , 52 :[ function ( require , module , exports ) {
41444152( function ( window , angular , undefined ) {
41454153 'use strict' ;
@@ -4296,4 +4304,4 @@ module.exports = {
42964304
42974305} , { "mout/array/contains" :1 , "mout/array/filter" :2 , "mout/array/slice" :5 , "mout/array/sort" :6 , "mout/array/toLookup" :7 , "mout/lang/isEmpty" :12 , "mout/object/deepMixIn" :19 , "mout/object/forOwn" :21 , "mout/string/makePath" :23 , "mout/string/upperCase" :24 } ] , "utils" :[ function ( require , module , exports ) {
42984306module . exports = require ( 'uE/lJt' ) ;
4299- } , { } ] } , { } , [ 52 ] )
4307+ } , { } ] } , { } , [ 52 ] )
0 commit comments