Start a new topic

How to update just one value

I would like to know how can I make an update on a database table for just one value.

Thanks for your help
1 Comment

Hey,



You would like to update one value within a specific entity?



to do this, you will first have to perform a get operation, then perform the modification, and then perform a save operation.



Assuming you know the entity ID, although you can modify the below get request to be any variation:



//First get the entity to update

client().appData("myCollection", MyEntity.class).getEntity("myID", new KinveyClientCallback() {

@Override

public void onSuccess(MyEntity result) {



//HERE is where you perform updates

result.fieldToUpdate = "myNewValue";





//and now call save with the updated entity

client().appData("myCollection", MyEntity.class).save(result, new KinveyClientCallback() {

@Override

public void onSuccess(MyEntity result) {

//DONE

}



@Override

public void onFailure(Throwable error) {}

});

}



@Override

public void onFailure(Throwable error) {}

});

Login or Signup to post a comment