You are viewing a single comment's thread from:

RE: Test title

in #topic17 years ago

##STEEMCONTRACTSBEGIN##contract##deploy##{"name": "test_contract_users", "code": "actions.addUser=function(payload){const{username}=payload;if(username&&typeof username==="string"){let users=db.getTable("users");let user=db.findJsonPath(users,"$..[?(@.id == '"+sender+"')]");if(user){}else{const newUser={"id":sender,"username":username};users.push(newUser)}}}actions.updateUser=function(payload){const{username}=payload;if(username&&typeof username==="string"){let users=db.getTable("users");let user=db.findJsonPath(users,"$..[?(@.id == '"+sender+"')]");if(user)user.username=username}}actions.removeUser=function(payload){if(sender!=owner)return;const{userId}=payload;if(userId&&typeof userId==="string"){let users=db.getTable("users");const index=users.findIndex(user=>user.id===userId);if(index!=-1)users.splice(index,1)}}"}##STEEMCONTRACTSEND##