nl_tokens: determine the set of operations to be executed
pl_tokens: function Operations ( ) { this . ifNotExistsSet = { } ; this . SET = { } ; this . ADD = { } ; this . REMOVE = { } ; this . LISTAPPEND = { } ; this . addIfNotExistsSet = function ( name , item ) { this . ifNotExistsSet [ name ] = item ; } ; this . addSet = function ( name , item ) { if ( schema . hashKey . name !== name && ( schema . rangeKey || { } ) . name !== name ) { this . SET [ name ] = item ; } } ; this . addListAppend = function ( name , item ) { if ( schema . hashKey . name !== name && ( schema . rangeKey || { } ) . <mask> !== name ) { this . LISTAPPEND [ name ] = item ; } } ; this . addAdd = function ( name , item ) { if ( schema . hashKey . name !== name && ( schema . rangeKey || { } ) . name !== name ) { this . ADD [ name ] = item ; } } ; this . addRemove = function ( name , item ) { if ( schema . hashKey . name !== name && ( schema . rangeKey || { } ) . name !== name ) { this . REMOVE [ name ] = item ; } } ; this . getUpdateExpression = function ( getUpdateReq ) { let attrCount = 0 ; let updateExpression = '' ; let attrName ; let valName ; let name ; let item ; const setExpressions = [ ] ; for ( name in this . ifNotExistsSet ) { item = this . ifNotExistsSet [ name ] ; attrName = ` ${ attrCount } ` ; valName = ` ${ attrCount } ` ; getUpdateReq . ExpressionAttributeNames [ attrName ] = name ; getUpdateReq . ExpressionAttributeValues [ valName ] = item ; setExpressions . push ( ` ${ attrName } ${ attrName } ${ valName } ` ) ; attrCount += 1 ; } for ( name in this . SET ) { item = this . SET [ name ] ; attrName = ` ${ attrCount } ` ; valName = ` ${ attrCount } ` ; getUpdateReq . ExpressionAttributeNames [ attrName ] = name ; getUpdateReq . ExpressionAttributeValues [ valName ] = item ; setExpressions . push ( ` ${ attrName } ${ valName } ` ) ; attrCount += 1 ; } for ( name in this . LISTAPPEND ) { item = this . LISTAPPEND [ name ] ; attrName = ` ${ attrCount } ` ; valName = ` ${ attrCount } ` ; getUpdateReq . ExpressionAttributeNames [ attrName ] = name ; getUpdateReq . ExpressionAttributeValues [ valName ] = item ; setExpressions . push ( ` ${ attrName } ${ attrName } ${ valName } ` ) ; attrCount += 1 ; } if ( setExpressions . length > 0 ) { updateExpression += ` ${ setExpressions . join ( ',' ) } ` ; } const addExpressions = [ ] ; for ( name in this . ADD ) { item = this . ADD [ name ] ; attrName = ` ${ attrCount } ` ; valName = ` ${ attrCount } ` ; getUpdateReq . ExpressionAttributeNames [ attrName ] = name ; getUpdateReq . ExpressionAttributeValues [ valName ] = item ; addExpressions . push ( ` ${ attrName } ${ valName } ` ) ; attrCount += 1 ; } if ( addExpressions . length > 0 ) { updateExpression += ` ${ addExpressions . join ( ',' ) } ` ; } const removeExpressions = [ ] ; for ( name in this . REMOVE ) { item = this . REMOVE [ name ] ; attrName = ` ${ attrCount } ` ; getUpdateReq . ExpressionAttributeNames [ attrName ] = name ; removeExpressions . push ( attrName ) ; attrCount += 1 ; } if ( removeExpressions . length > 0 ) { updateExpression += ` ${ removeExpressions . join ( ',' ) } ` ; } getUpdateReq . UpdateExpression = updateExpression ; } ; }