Skip to content

Instantly share code, notes, and snippets.

@spacenick
Last active December 16, 2015 07:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save spacenick/5397435 to your computer and use it in GitHub Desktop.
Save spacenick/5397435 to your computer and use it in GitHub Desktop.
Adding item to a relation on Parse
// You can do that in your Chrome Console
// Load the initial object, like an Attempt
var attempt = new Parse.Object("Attempt");
attempt.id = "myId";
attempt.fetch();
// Get the relation "handler" from the attempt object
var relation = attempt.relation("products");
// Add some products to the relation. They don't need to be fetched, just to have an "id" property
var product = new Parse.Object("Products");
product.id = "id1";
relation.add(product);
// Let's add others product, we can use the same object as only the id matters
product.id = "id2";
relation.add(product);
// let's save the object to reflect the changes in Parse
attempt.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment