Skip to content

Instantly share code, notes, and snippets.

@r3b
Created August 25, 2014 01:41
Show Gist options
  • Save r3b/53f6b92f6066158b3a12 to your computer and use it in GitHub Desktop.
Save r3b/53f6b92f6066158b3a12 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Update Test</title>
<script src="./js/usergrid.js"></script>
<script type="text/javascript">
var restaurants;
var client = new Usergrid.Client({
URI: 'http://10.1.1.161:8080',
orgName: 'test-organization',
appName: 'restaurants'
});
var name = "Restaurant A"
var city = "City X"
var data = {
type: "restaurant",
name: name,
city: city
};
client.createEntity(data, function(error, response) {
if (error) {
alert("Error creating entity");
} else {
alert("Created entity");
}
});
var identifier = {
name: name,
type: "restaurant"
};
client.getEntity(identifier, function(err, response) {
if (err) {
alert("Error getting entity to be updated");
} else {
var restaurant = response.entities[0];
restaurant.set({ city: "Other City"}, function(err) {
if (err) {
alert("Error updating entity");
} else {
alert("Updated entity");
}
});
}
});
</script>
</head>
<body>
Update Test
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment