Skip to content

Instantly share code, notes, and snippets.

@niraj-shah
Created July 3, 2014 12:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save niraj-shah/40c978e9d87594a97e3f to your computer and use it in GitHub Desktop.
Save niraj-shah/40c978e9d87594a97e3f to your computer and use it in GitHub Desktop.
Parse.com JavaScript SDK - Using Pointers and ACL
// new Profile object
var Profile = Parse.Object.extend("Profile");
var profile = new Profile();
// set DOB as date - needs to be ISO format
var dob = new Date("1985-01-01");
profile.set( 'dob', { "__type": "Date", "iso": dob.toISOString() } );
// bio string data
profile.set( 'bio', 'I am a PHP developer' );
// pointer to User table (parse Classes should have _ prefix.)
profile.set( "userId", { "__type": "Pointer", "className": "_User", "objectId": Parse.User.current().id } );
// create ACL
var acl = new Parse.ACL();
// public cannot read data
acl.setPublicReadAccess(false);
// user can read data
acl.setReadAccess( Parse.User.current(), true );
// save ACL to object
profile.setACL( acl );
profile.save(null, {
success: function(item) {
// success callback
},
error: function(item, error) {
// error callback
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment