sdk/src/sync/MobileServiceSyncContext.js
function upsertWithLogging(tableName, instance, action, shouldOverwrite) {
        Validate.isString(tableName, 'tableName');
        Validate.notNullOrEmpty(tableName, 'tableName');

        Validate.notNull(instance, 'instance');
        Validate.isValidId(instance.id, 'instance.id');
        
        if (!store) {
            throw new Error('MobileServiceSyncContext not initialized');
        }
        
        return store.lookup(tableName, instance.id, true /* suppressRecordNotFoundError */).then(function(existingRecord) {
            if (existingRecord && !shouldOverwrite) {
                throw new Error('Record with id ' + existingRecord.id + ' already exists in the table ' + tableName);
            }
        }).then(function() {
            return operationTableManager.getLoggingOperation(tableName, action, instance);
        }).then(function(loggingOperation) {
            return store.executeBatch([
                {
                    action: 'upsert',
                    tableName: tableName,
                    data: instance
                },
                loggingOperation
            ]);
        }).then(function() {
            return instance;
        });
    }
function upsertWithLogging(tableName, instance, action, shouldOverwrite) {
        Validate.isString(tableName, 'tableName');
        Validate.notNullOrEmpty(tableName, 'tableName');

        Validate.notNull(instance, 'instance');
        Validate.isValidId(instance.id, 'instance.id');
        
        if (!store) {
            throw new Error('MobileServiceSyncContext not initialized');
        }
        
        return store.lookup(tableName, instance.id, true /* suppressRecordNotFoundError */).then(function(existingRecord) {
            if (existingRecord && !shouldOverwrite) {
                throw new Error('Record with id ' + existingRecord.id + ' already exists in the table ' + tableName);
            }
        }).then(function() {
            return operationTableManager.getLoggingOperation(tableName, action, instance);
        }).then(function(loggingOperation) {
            return store.executeBatch([
                {
                    action: 'upsert',
                    tableName: tableName,
                    data: instance
                },
                loggingOperation
            ]);
        }).then(function() {
            return instance;
        });
    }
function upsertWithLogging ( tableName , instance , action , shouldOverwrite ) { Validate . isString ( tableName , 'tableName' ) ; Validate . notNullOrEmpty ( tableName , 'tableName' ) ; Validate . notNull ( instance , 'instance' ) ; Validate . isValidId ( instance . id , 'instance.id' ) ; if ( ! store ) { throw new Error ( 'MobileServiceSyncContext not initialized' ) ; } return store . lookup ( tableName , instance . id , true /* suppressRecordNotFoundError */ ) . then ( function ( existingRecord ) { if ( existingRecord && ! shouldOverwrite ) { throw new Error ( 'Record with id ' + existingRecord . id + ' already exists in the table ' + tableName ) ; } } ) . then ( function ( ) { return operationTableManager . getLoggingOperation ( tableName , action , instance ) ; } ) . then ( function ( loggingOperation ) { return store . executeBatch ( [ { action : 'upsert' , tableName : tableName , data : instance } , loggingOperation ] ) ; } ) . then ( function ( ) { return instance ; } ) ; }
Performs upsert and logs the action in the operation table Validates parameters. Callers can skip validation
Performs upsert and logs the action in the operation table Validates parameters . Callers can skip validation