import { UpdateType , ScalarType } from '@typedorm/common' ; import { Update } from './update' ; export class SetUpdate extends Update { protected prefix : UpdateType . Action = 'SET' ; /**
     * Support specifying additional arithmetic operations
     */ setTo ( key , value , incrementBy ? ) { const arithmeticOperator = incrementBy ? this . getSymbolForArithmeticOperator ( incrementBy ) : '' ; const attrExpName = this . addExpressionName ( key ) ; const attrExpValue = this . addExpressionValue ( key , value ) ; this . appendToExpression ( `${ attrExpName } ` + `${ this . getSymbolForOperator ( 'EQ' ) } ` + `${ arithmeticOperator ? `${ attrExpName } ${ arithmeticOperator } ` : '' }` + `${ attrExpValue }` ) ; return this ; } setToIfNotExists ( key , value , otherKeyAttribute ? ) { const attrExpName = this . addExpressionName ( key ) ; const attrExpValue = this . addExpressionValue ( key , value ) ; const keyofValueToCheck = otherKeyAttribute ? this . addExpressionName ( otherKeyAttribute ) : attrExpName ; this . appendToExpression ( `${ attrExpName } ` + `${ this . getSymbolForOperator ( 'EQ' ) } ` + `if_not_exists(${ keyofValueToCheck }, ${ attrExpValue })` ) ; return this ; } setOrAppendToList ( key , value , otherKeyAttribute ? ) { const attrExpName = this . addExpressionName ( key ) ; const attrExpValue = this . addExpressionValue ( key , value ) ; const keyofValueToAppend = otherKeyAttribute ? this . addExpressionName ( otherKeyAttribute ) : attrExpName ; this . appendToExpression ( `${ attrExpName } ` + `${ this . getSymbolForOperator ( 'EQ' ) } ` + `list_append(${ keyofValueToAppend }, ${ attrExpValue })` ) ; return this ; } }