Full Update without the Overwrite Check

This method overwrites the data on the server with the key-value pairs sent from the client (the data on the server will be lost).

The data will be overwritten unconditionally regardless of if the data on the server is updated by other clients.

Here is the sample code:

  • // Instantiate a KiiObject.
    var object2 = KiiObject.objectWithURI(object.objectURI());
    
    // Update key-value pairs.
    object2.set("myid", 1);
    object2.set("name", "John Doe Jr");
    object2.set("email", "john_jr@example.com");
    object2.remove("address");
    
    // Save and fully update the KiiObject.
    // This method removes all key-value pairs from the KiiObject on the server and
    // adds the key-value pairs generated locally to the KiiObject.
    object2.saveAllFields({
      success: function(theObject) {
        // Do something.
      },
      failure: function(theObject, errorString) {
        // Handle the error.
      }
    });
  • // Instantiate a KiiObject.
    var object2 = KiiObject.objectWithURI(object.objectURI());
    
    // Update key-value pairs.
    object2.set("myid", 1);
    object2.set("name", "John Doe Jr");
    object2.set("email", "john_jr@example.com");
    object2.remove("address");
    
    // Save and fully update the KiiObject.
    // This method removes all key-value pairs from the KiiObject on the server and
    // adds the key-value pairs generated locally to the KiiObject.
    object2.saveAllFields().then(
      function(theObject) {
        // Do something.
      }
    ).catch(
      function(error) {
        var theObject = error.target;
        var errorString = error.message;
        // Handle the error.
      }
    );

This is what is happening in the sample code:

  1. Prepare a KiiObject to update. In this sample code, we are creating a KiiObject with its URI (Replace the URI in the code with the real one when you are running the code).
  2. Add key-value pairs with the set() method and remove a key-value pair with the remove() method. Only the key-value pairs set here will be in the KiiOject after the updating. If you need to do so, you can execute the refresh() method beforehand to get all key-value pairs in the server (See Getting a KiiObject for the implementation example).
  3. Execute the saveAllFields() method to update the KiiObject. We are not using the overwrite check so that the update will be made unconditionally.