Constructor
new Role(name, acl)
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the Role to create. |
acl |
Parse.ACL | The ACL for this role. Roles must have an ACL. A Parse.Role is a local representation of a role persisted to the Parse cloud. |
Extends
Members
attributes
Prototype getters / setters
- Inherited From:
createdAt :Date
The first time this object was saved on the server.
Type:
- Date
Properties:
Name | Type | Description |
---|---|---|
createdAt |
- Inherited From:
updatedAt :Date
The last time this object was updated on the server.
Type:
- Date
Properties:
Name | Type | Description |
---|---|---|
updatedAt |
- Inherited From:
Methods
_getId()
Returns a local or server Id used uniquely identify this object
- Inherited From:
_getStateIdentifier()
Returns a unique identifier used to pull data from the State Controller.
- Inherited From:
add(attr, item) → {ParseObject|Boolean}
Atomically add an object to the end of the array associated with a given
key.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The key. |
item |
The item to add. |
- Inherited From:
Returns:
- Type
- ParseObject | Boolean
addAll(attr, items)
Atomically add the objects to the end of the array associated with a given
key.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The key. |
items |
Array.<Object> | The items to add. |
- Inherited From:
addAllUnique(attr, items)
Atomically add the objects to the array associated with a given key, only
if it is not already present in the array. The position of the insert is
not guaranteed.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The key. |
items |
Array.<Object> | The objects to add. |
- Inherited From:
addUnique(attr, item)
Atomically add an object to the array associated with a given key, only
if it is not already present in the array. The position of the insert is
not guaranteed.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The key. |
item |
The object to add. |
- Inherited From:
clear() → {ParseObject|boolean}
Clears all attributes on a model
- Inherited From:
Returns:
- Type
- ParseObject | boolean
clone() → {Parse.Object}
Creates a new model with identical attributes to this one, similar to Backbone.Model's clone()
- Inherited From:
Returns:
- Type
- Parse.Object
destroy(options) → {Parse.Promise}
Destroy this model on the server if it was already persisted.
If `wait: true` is passed, waits for the server to respond
before removal.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | A Backbone-style callback object.
Valid options are:
|
- Inherited From:
Returns:
A promise that is fulfilled when the destroy
completes.
- Type
- Parse.Promise
dirty(attr) → {Boolean}
Returns true if this object has been modified since its last
save/refresh. If an attribute is specified, it returns true only if that
particular attribute has been modified since the last save/refresh.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | An attribute name (optional). |
- Inherited From:
Returns:
- Type
- Boolean
dirtyKeys() → {Array.<String>}
Returns an array of keys that have been modified since last save/refresh
- Inherited From:
Returns:
- Type
- Array.<String>
equals(other) → {Boolean}
Determines whether this ParseObject is equal to another ParseObject
Parameters:
Name | Type | Description |
---|---|---|
other |
Object | An other object ot compare |
- Inherited From:
Returns:
- Type
- Boolean
escape(attr)
Gets the HTML-escaped value of an attribute.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The string name of an attribute. |
- Inherited From:
existed() → {Boolean}
Returns true if this object was created by the Parse server when the
object might have already been there (e.g. in the case of a Facebook
login)
- Inherited From:
Returns:
- Type
- Boolean
fetch(options) → {Parse.Promise}
Fetch the model from the server. If the server's representation of the
model differs from its current attributes, they will be overriden.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | A Backbone-style callback object.
Valid options are:
|
- Inherited From:
Returns:
A promise that is fulfilled when the fetch
completes.
- Type
- Parse.Promise
get(attr)
Gets the value of an attribute.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The string name of an attribute. |
- Inherited From:
getACL() → {Parse.ACL}
Returns the ACL for this object.
- Inherited From:
- See:
Returns:
An instance of Parse.ACL.
- Type
- Parse.ACL
getName() → {String}
Gets the name of the role. You can alternatively call role.get("name")
Returns:
the name of the role.
- Type
- String
getRoles() → {Parse.Relation}
Gets the Parse.Relation for the Parse.Roles that are direct
children of this role. These roles' users are granted any privileges that
this role has been granted (e.g. read or write access through ACLs). You
can add or remove child roles from this role through this relation.
This is equivalent to calling role.relation("roles")
Returns:
the relation for the roles belonging to this
role.
- Type
- Parse.Relation
getUsers() → {Parse.Relation}
Gets the Parse.Relation for the Parse.Users that are direct
children of this role. These users are granted any privileges that this
role has been granted (e.g. read or write access through ACLs). You can
add or remove users from the role through this relation.
This is equivalent to calling role.relation("users")
Returns:
the relation for the users belonging to this
role.
- Type
- Parse.Relation
has(attr) → {Boolean}
Returns
true
if the attribute contains a value that is not
null or undefined.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The string name of the attribute. |
- Inherited From:
Returns:
- Type
- Boolean
increment(attr, amount)
Atomically increments the value of the given attribute the next time the
object is saved. If no amount is specified, 1 is used by default.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The key. |
amount |
Number | The amount to increment by (optional). |
- Inherited From:
initialize()
Public methods
- Inherited From:
isNew() → {Boolean}
Returns true if this object has never been saved to Parse.
- Inherited From:
Returns:
- Type
- Boolean
isValid() → {Boolean}
Checks if the model is currently in a valid state.
- Inherited From:
Returns:
- Type
- Boolean
newInstance() → {Parse.Object}
Creates a new instance of this object. Not to be confused with clone()
- Inherited From:
Returns:
- Type
- Parse.Object
op(attr) → {Parse.Op}
Returns an instance of a subclass of Parse.Op describing what kind of
modification has been performed on this field since the last time it was
saved. For example, after calling object.increment("x"), calling
object.op("x") would return an instance of Parse.Op.Increment.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The key. |
- Inherited From:
Returns:
The operation, or undefined if none.
- Type
- Parse.Op
relation(String) → {Parse.Relation}
Gets a relation on the given class for the attribute.
Parameters:
Name | Type | Description |
---|---|---|
String |
attr The attribute to get the relation for. |
- Inherited From:
Returns:
- Type
- Parse.Relation
remove(attr, item)
Atomically remove all instances of an object from the array associated
with a given key.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The key. |
item |
The object to remove. |
- Inherited From:
removeAll(attr, items)
Atomically remove all instances of the objects from the array associated
with a given key.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The key. |
items |
Array.<Object> | The object to remove. |
- Inherited From:
revert()
Clears any changes to this object made since the last call to save()
- Inherited From:
save(options) → {Parse.Promise}
Set a hash of model attributes, and save the model to the server.
updatedAt will be updated when the request returns.
You can either call it as:
object.save();or
object.save(null, options);or
object.save(attrs, options);or
object.save(key, value, options);For example,
gameTurn.save({ player: "Jake Cutter", diceRoll: 2 }, { success: function(gameTurnAgain) { // The save was successful. }, error: function(gameTurnAgain, error) { // The save failed. Error is an instance of Parse.Error. } });or with promises:
gameTurn.save({ player: "Jake Cutter", diceRoll: 2 }).then(function(gameTurnAgain) { // The save was successful. }, function(error) { // The save failed. Error is an instance of Parse.Error. });
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | A Backbone-style callback object.
Valid options are:
|
- Inherited From:
Returns:
A promise that is fulfilled when the save
completes.
- Type
- Parse.Promise
set(key, value, options) → {Boolean}
Sets a hash of model attributes on the object.
You can call it with an object containing keys and values, or with one key and value. For example:
gameTurn.set({ player: player1, diceRoll: 2 }, { error: function(gameTurnAgain, error) { // The set failed validation. } }); game.set("currentPlayer", player2, { error: function(gameTurnAgain, error) { // The set failed validation. } }); game.set("finished", true);
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The key to set. |
value |
The value to give it. | |
options |
Object | A set of options for the set.
The only supported option is error . |
- Inherited From:
Returns:
true if the set succeeded.
- Type
- Boolean
setACL(acl, options) → {Boolean}
Sets the ACL to be used for this object.
Parameters:
Name | Type | Description |
---|---|---|
acl |
Parse.ACL | An instance of Parse.ACL. |
options |
Object | Optional Backbone-like options object to be passed in to set. |
- Inherited From:
- See:
Returns:
Whether the set passed validation.
- Type
- Boolean
setName(name, options)
Sets the name for a role. This value must be set before the role has
been saved to the server, and cannot be set once the role has been
saved.
A role's name can only contain alphanumeric characters, _, -, and spaces.
This is equivalent to calling role.set("name", name)
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the role. |
options |
Object | Standard options object with success and error callbacks. |
toJSON() → {Object}
Returns a JSON version of the object suitable for saving to Parse.
- Inherited From:
Returns:
- Type
- Object
toPointer() → {Pointer}
Gets a Pointer referencing this Object.
- Inherited From:
Returns:
- Type
- Pointer
unset(attr)
Remove an attribute from the model. This is a noop if the attribute doesn't
exist.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The string name of an attribute. |
- Inherited From:
validate(attrs)
You should not call this function directly unless you subclass
Parse.Object
, in which case you can override this method
to provide additional validation on set
and
save
. Your implementation should return
Parameters:
Name | Type | Description |
---|---|---|
attrs |
Object | The current data to validate. |
- Overrides:
- See:
Returns:
False if the data is valid. An error object otherwise.