sdk/src/sync/pull.js
function pull(query, queryId, settings) {
        //TODO: support pullQueryId
        //TODO: page size should be configurable
        
        return pullTaskRunner.run(function() {
            validateQuery(query, 'query');
            Validate.isString(queryId, 'queryId'); // non-null string or null - both are valid
            Validate.isObject(settings, 'settings');

            settings = settings || {};
            if (_.isNull(settings.pageSize)) {
                pageSize = defaultPageSize;
            } else if (_.isInteger(settings.pageSize) && settings.pageSize > 0) {
                pageSize = settings.pageSize;
            } else {
                throw new Error('Page size must be a positive integer. Page size ' + settings.pageSize + ' is invalid.');
            }

            // Make a copy of the query as we will be modifying it
            tablePullQuery = copyQuery(query);            

            mobileServiceTable = client.getTable(tablePullQuery.getComponents().table);
            mobileServiceTable._features = queryId ? [constants.features.OfflineSync, constants.features.IncrementalPull] : [constants.features.OfflineSync];
            pullQueryId = queryId;

            // Set up the query for initiating a pull and then pull all pages          
            return setupQuery().then(function() {
                return pullAllPages();
            });
        });
    }
function pull(query, queryId, settings) {
        //TODO: support pullQueryId
        //TODO: page size should be configurable
        
        return pullTaskRunner.run(function() {
            validateQuery(query, 'query');
            Validate.isString(queryId, 'queryId'); // non-null string or null - both are valid
            Validate.isObject(settings, 'settings');

            settings = settings || {};
            if (_.isNull(settings.pageSize)) {
                pageSize = defaultPageSize;
            } else if (_.isInteger(settings.pageSize) && settings.pageSize > 0) {
                pageSize = settings.pageSize;
            } else {
                throw new Error('Page size must be a positive integer. Page size ' + settings.pageSize + ' is invalid.');
            }

            // Make a copy of the query as we will be modifying it
            tablePullQuery = copyQuery(query);            

            mobileServiceTable = client.getTable(tablePullQuery.getComponents().table);
            mobileServiceTable._features = queryId ? [constants.features.OfflineSync, constants.features.IncrementalPull] : [constants.features.OfflineSync];
            pullQueryId = queryId;

            // Set up the query for initiating a pull and then pull all pages          
            return setupQuery().then(function() {
                return pullAllPages();
            });
        });
    }
function pull ( query , queryId , settings ) { //TODO: support pullQueryId //TODO: page size should be configurable return pullTaskRunner . run ( function ( ) { validateQuery ( query , 'query' ) ; Validate . isString ( queryId , 'queryId' ) ; // non-null string or null - both are valid Validate . isObject ( settings , 'settings' ) ; settings = settings || { } ; if ( _ . isNull ( settings . pageSize ) ) { pageSize = defaultPageSize ; } else if ( _ . isInteger ( settings . pageSize ) && settings . pageSize > 0 ) { pageSize = settings . pageSize ; } else { throw new Error ( 'Page size must be a positive integer. Page size ' + settings . pageSize + ' is invalid.' ) ; } // Make a copy of the query as we will be modifying it tablePullQuery = copyQuery ( query ) ; mobileServiceTable = client . getTable ( tablePullQuery . getComponents ( ) . table ) ; mobileServiceTable . _features = queryId ? [ constants . features . OfflineSync , constants . features . IncrementalPull ] : [ constants . features . OfflineSync ] ; pullQueryId = queryId ; // Set up the query for initiating a pull and then pull all pages           return setupQuery ( ) . then ( function ( ) { return pullAllPages ( ) ; } ) ; } ) ; }
Pulls changes from the server tables into the local store.

@param query Query specifying which records to pull
@param pullQueryId A unique string ID for an incremental pull query OR null for a vanilla pull query.
@param [settings] An object that defines the various pull settings - currently only pageSize

@returns A promise that is fulfilled when all records are pulled OR is rejected if the pull fails or is cancelled.
Pulls changes from the server tables into the local store .