new Entity()
- Source:
Extends
Members
(readonly) acl :Acl
The object read/write permissions
Type:
- Source:
(readonly) createdAt :Date
Date of the creation of the object
Type:
- Date
- 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
- 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
- Source:
(readonly) updatedAt :Date
Last update date of the object
Type:
- Date
- Source:
(readonly) version :number
The version of this object
Type:
- number
- Source:
Methods
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 |
- 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. |
- 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
|
- Source:
Returns:
A promise resolving with an array of all referencing objects
- Type
- Promise.<binding.Entity>
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. |
- 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. |
- 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. |
- 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> |
- 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 |
- Source:
Returns:
A promise which completes successfully, when the previously requested
operation completes
- Type
- Promise.<this>
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. |
- 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
|
- Overrides:
- 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. |
- 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
- Source:
Returns:
Contains the result of the Validation
Type Definitions
doneCallback(entity) → {Promise.<*>|*}
The done callback is called, when the asynchronous operation completes successfully
Parameters:
Name | Type | Description |
---|---|---|
entity |
this | This entity |
- Source:
Returns:
A Promise, result or undefined
- Type
- Promise.<*> | *
failCallback(error) → {Promise.<*>|*}
The fail callback is called, when the asynchronous operation is rejected by an error
Parameters:
Name | Type | Description |
---|---|---|
error |
error.PersistentError | The error which reject the operation |
- Source:
Returns:
A Promise, result or undefined
- Type
- Promise.<*> | *