|
769 | 769 | * Fetch the model from the server. If the server's representation of the |
770 | 770 | * model differs from its current attributes, they will be overriden, |
771 | 771 | * triggering a <code>"change"</code> event. |
| 772 | + * @param {Object} fetchOptions Optional options to set 'keys' and |
| 773 | + * 'include' option. |
772 | 774 | * @param {Object} options Optional Backbone-like options object to be |
773 | | - * passed in to set. Also you can set 'keys' and 'include' options. |
| 775 | + * passed in to set. |
774 | 776 | * @return {AV.Promise} A promise that is fulfilled when the fetch |
775 | 777 | * completes. |
776 | 778 | */ |
777 | | - fetch: function(options) { |
778 | | - var include = null; |
779 | | - var keys = null; |
780 | | - if(options) { |
781 | | - var processOpt = function(k) { |
782 | | - if(options[k]){ |
783 | | - if(_.isArray(options[k])) { |
784 | | - return options[k].join(','); |
785 | | - } else { |
786 | | - return options[k]; |
787 | | - } |
788 | | - } |
789 | | - }; |
790 | | - include = processOpt('include'); |
791 | | - keys = processOpt('keys'); |
| 779 | + fetch: function() { |
| 780 | + var options = null; |
| 781 | + var fetchOptions = {}; |
| 782 | + if(arguments.length == 1) { |
| 783 | + options = arguments[0]; |
| 784 | + } else if(arguments.length == 2) { |
| 785 | + fetchOptions = arguments[0]; |
| 786 | + options = arguments[1]; |
792 | 787 | } |
| 788 | + |
793 | 789 | var self = this; |
794 | 790 | var request = AV._request("classes", this.className, this.id, 'GET', |
795 | | - { include: include, keys: keys}); |
| 791 | + fetchOptions); |
796 | 792 | return request.then(function(response, status, xhr) { |
797 | 793 | self._finishFetch(self.parse(response, status, xhr), true); |
798 | 794 | return self; |
|
0 commit comments