new Role()
- Source:
Extends
Members
(readonly) acl :Acl
The object read/write permissions
Type:
- Inherited From:
- Source:
(readonly) createdAt :Date
Date of the creation of the object
Type:
- Date
- Inherited From:
- Source:
id :string
The unique id of this object
Sets the unique id of this object, if the id is not formatted as an valid id,
it will be used as the key component of the id has the same affect as setting the key
Type:
- string
- Inherited From:
- Source:
key :string
The unique key part of the id
When the key of the unique id is set an error will be thrown if an id is already set.
Type:
- string
- Inherited From:
- Source:
name :string
The name of the role
Type:
- string
- Source:
(readonly) updatedAt :Date
Last update date of the object
Type:
- Date
- Inherited From:
- Source:
users :Set.<model.User>
A set of users which have this role
Type:
- Set.<model.User>
- Source:
(readonly) version :number
The version of this object
Type:
- number
- Inherited From:
- Source:
Methods
addUser(user) → {void}
Add the given user to this role
Parameters:
Name | Type | Description |
---|---|---|
user |
model.User | The user to add |
- Source:
Returns:
- Type
- void
attach(db) → {void}
Attach this object to the given db
Parameters:
Name | Type | Description |
---|---|---|
db |
EntityManager | The db which will be used for future crud operations |
- Inherited From:
- Source:
Returns:
- Type
- void
delete(optionsopt, doneCallbackopt, failCallbackopt) → {Promise.<this>}
Deletes an existing object
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The remove options |
|||||||||||||||
Properties
|
||||||||||||||||||
doneCallback |
binding.Entity~doneCallback |
<optional> |
Called when the operation succeed. |
|||||||||||||||
failCallback |
binding.Entity~failCallback |
<optional> |
Called when the operation failed. |
- Inherited From:
- Source:
Returns:
A Promise that will be fulfilled when the asynchronous operation completes.
- Type
- Promise.<this>
getReferencing(optionsopt) → {Promise.<binding.Entity>}
Get all objects which refer to this object
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Some options to pass |
||||||||
Properties
|
- Inherited From:
- Source:
Returns:
A promise resolving with an array of all referencing objects
- Type
- Promise.<binding.Entity>
hasUser(user) → {boolean}
Test if the given user has this role
Parameters:
Name | Type | Description |
---|---|---|
user |
model.User | The user to check |
- Source:
Returns:
true
if the given user has this role,
otherwise false
- Type
- boolean
insert(optionsopt, doneCallbackopt, failCallbackopt) → {Promise.<this>}
Inserts a new object. Inserts the object if it doesn't exists and raise an error if the object already exist.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The insertion options |
|||||||||||||||
Properties
|
||||||||||||||||||
doneCallback |
binding.Entity~doneCallback |
<optional> |
Called when the operation succeed. |
|||||||||||||||
failCallback |
binding.Entity~failCallback |
<optional> |
Called when the operation failed. |
- Inherited From:
- Source:
Returns:
A Promise that will be fulfilled when the asynchronous operation completes.
- Type
- Promise.<this>
load(optionsopt, doneCallbackopt, failCallbackopt) → {Promise.<this>}
Resolves the referenced object in the specified depth
Only unresolved objects will be loaded unless the refresh option is specified.
Removed objects will be marked as removed.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The load options |
|||||||||||||||
Properties
|
||||||||||||||||||
doneCallback |
binding.Entity~doneCallback |
<optional> |
Called when the operation succeed. |
|||||||||||||||
failCallback |
binding.Entity~failCallback |
<optional> |
Called when the operation failed. |
- Inherited From:
- Source:
Returns:
A Promise that will be fulfilled when the asynchronous operation completes.
- Type
- Promise.<this>
optimisticSave(cb, doneCallbackopt, failCallbackopt) → {Promise.<this>}
Saves the object and repeats the operation if the object is out of date
In each pass the callback will be called. Ths first parameter of the callback is the entity and the second one
is a function to abort the process.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cb |
function | Will be called in each pass |
|
doneCallback |
binding.Entity~doneCallback |
<optional> |
Called when the operation succeed. |
failCallback |
binding.Entity~failCallback |
<optional> |
Called when the operation failed. |
- Inherited From:
- Source:
Returns:
A Promise that will be fulfilled when the asynchronous operation completes.
- Type
- Promise.<this>
partialUpdate(operationsopt) → {partialupdate.EntityPartialUpdateBuilder.<this>}
Starts a partial update on this entity
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
operations |
json |
<optional> |
- Inherited From:
- Source:
Returns:
ready(doneCallbackopt) → {Promise.<this>}
Waits on the previously requested operation on this object completes
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
doneCallback |
binding.Entity~doneCallback |
<optional> |
The callback which will be invoked when the previously |
- Inherited From:
- Source:
Returns:
A promise which completes successfully, when the previously requested
operation completes
- Type
- Promise.<this>
removeUser(user) → {void}
Remove the given user from this role
Parameters:
Name | Type | Description |
---|---|---|
user |
model.User | The user to remove |
- Source:
Returns:
- Type
- void
save(optionsopt, doneCallbackopt, failCallbackopt) → {Promise.<this>}
Saves the object. Inserts the object if it doesn't exists and updates the object if the object exist.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The save options |
||||||||||||||||||||
Properties
|
|||||||||||||||||||||||
doneCallback |
binding.Entity~doneCallback |
<optional> |
Called when the operation succeed. |
||||||||||||||||||||
failCallback |
binding.Entity~failCallback |
<optional> |
Called when the operation failed. |
- Inherited From:
- Source:
Returns:
A Promise that will be fulfilled when the asynchronous operation completes.
- Type
- Promise.<this>
toJSON(optionsopt) → {json}
Converts the object to an JSON-Object
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | boolean |
<optional> |
false | to json options by default excludes the metadata |
||||||||||||||
Properties
|
- Inherited From:
- Source:
Returns:
JSON-Object
- Type
- json
update(optionsopt, doneCallbackopt, failCallbackopt) → {Promise.<this>}
Updates an existing object
Updates the object if it exists and raise an error if the object doesn't exist.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The update options |
||||||||||||||||||||
Properties
|
|||||||||||||||||||||||
doneCallback |
binding.Entity~doneCallback |
<optional> |
Called when the operation succeed. |
||||||||||||||||||||
failCallback |
binding.Entity~failCallback |
<optional> |
Called when the operation failed. |
- Inherited From:
- Source:
Returns:
A Promise that will be fulfilled when the asynchronous operation completes.
- Type
- Promise.<this>
validate() → {util.ValidationResult}
Validates the entity by using the validation code of the entity type
- Inherited From:
- Source:
Returns:
Contains the result of the Validation