File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -1736,6 +1736,10 @@ module.exports = function(AV) {
17361736 method : method ,
17371737 path : path ,
17381738 body : json ,
1739+ params :
1740+ options && options . fetchWhenSave
1741+ ? { fetchWhenSave : true }
1742+ : undefined ,
17391743 } ;
17401744 } ) ,
17411745 } ,
Original file line number Diff line number Diff line change @@ -379,6 +379,24 @@ module.exports = function(AV) {
379379 return request . then ( this . _parseResponse . bind ( this ) ) ;
380380 } ,
381381
382+ /**
383+ * Retrieves both AVObjects and total count.
384+ *
385+ * @since 4.12.0
386+ * @param {AuthOptions } options
387+ * @return {Promise } A tuple contains results and count.
388+ */
389+ findAndCount ( options ) {
390+ const params = this . _getParams ( ) ;
391+ params . count = 1 ;
392+ const request = this . _createRequest ( params , options ) ;
393+
394+ return request . then ( response => [
395+ this . _parseResponse ( response ) ,
396+ response . count ,
397+ ] ) ;
398+ } ,
399+
382400 /**
383401 * scan a Query. masterKey required.
384402 *
Original file line number Diff line number Diff line change @@ -411,7 +411,9 @@ export namespace Object {
411411 query ?: Query < T > ;
412412 }
413413
414- interface SaveAllOptions extends AuthOptions { }
414+ interface SaveAllOptions extends AuthOptions {
415+ fetchWhenSave ?: boolean ;
416+ }
415417
416418 interface SetOptions extends SilentOption { }
417419}
@@ -581,6 +583,7 @@ export class Query<T extends Queriable> extends BaseQuery<T> {
581583 endsWith ( key : string , suffix : string ) : this;
582584 equalTo ( key : string , value : any ) : this;
583585 exists ( key : string ) : this;
586+ findAndCount ( options ?: AuthOptions ) : Promise < [ T [ ] , number ] > ;
584587 first ( options ?: AuthOptions ) : Promise < T | undefined > ;
585588 get ( objectId : string , options ?: AuthOptions ) : Promise < T > ;
586589 greaterThan ( key : string , value : any ) : this;
You can’t perform that action at this time.
0 commit comments