service-entity-models v3.0.1
service-entity-models
The Augmented.js Next Service - Entity Models Module.
API
Table of Contents
- ResourceCollection
- EntityCollection
- PaginatedResourceCollection
- PaginationFactory
- PaginationFactory.type
- Entity
- Resource
ResourceCollection
Extends AbstractCollection
Collection class to handle REST
Parameters
modelsoptions(optional, default{})
uri
Collection name for us in a datasource or an identifier
Properties
namestring The name of the collection
uri
Properties
uristring The uri for the resource
url
Meta
- deprecated: This is deprecated.
sync
Sync method to handle REST functions for the model
Parameters
fetch
Fetch the entity
Parameters
optionsobject Any options to pass
save
Save the entity
Parameters
optionsobject Any options to pass
update
Update the entity
Parameters
optionsobject Any options to pass
destroy
Destroy the entity
Parameters
optionsobject Any options to pass
EntityCollection
Extends AbstractCollection
Collection class to handle ORM to a datasource</br/> Note: Datasource property is required
Parameters
modelsoptions
uri
Collection name for us in a datasource or an identifier
Properties
namestring The name of the collection
uri
The query to use for the query - defaults to "id" selection
uri
Properties
uristring The uri for the datasource (if applicable)
uri
Returns (string | function) uri The URI or a function to retun a URI object
url
Meta
- deprecated: This is deprecated.
initialize
Initialize the model with needed wireing
Parameters
optionsobject Any options to pass
init
Custom init method for the model (called at initialize)
Parameters
optionsobject Any options to pass
setDatasource
Parameters
datasource
Properties
datasourceAugmented.Service.DataSource Datasource instance
setDatasource
Set the datasource for the Collection
Parameters
datasourceobject The datasource object
sync
Sync method to handle datasource functions for the Collection
Parameters
fetch
Fetch the entity
Parameters
optionsobject Any options to pass
save
Save the entity
Parameters
optionsobject Any options to pass
update
Update the entity
Parameters
optionsobject Any options to pass
destroy
Destroy the entity
Parameters
optionsobject Any options to pass
setDataSourceCollection
Set the DataSource Collection
Parameters
namestring The name of the collection datasouce
PaginatedResourceCollection
Extends ResourceCollection
Collection class to handle ORM to a datasource with pagination</br/> Note: Datasource property is required
Parameters
modelsoptions
setPageSize
Sets the number of items in a page
Parameters
sizenumber Number of items in each page
setCurrentPage
Sets the current page
Parameters
pagenumber Current page in collection
fetch
Fetch the entity
Parameters
optionsobject Any options to pass
nextPage
Moves to the next page
previousPage
Moves to the previous page
goToPage
Goes to page
Parameters
pagenumber Page to go to
firstPage
Moves to the first page
lastPage
Moves to the last page
refresh
Refreshes the collection
PaginationFactory
Pagination factory for returning pagination collections of an API type
getPaginatedCollection
Get a pagination collection of type
Parameters
CollectionPAGINATION_API The collection class to enrichapiTypePAGINATION_API The API type to return an instance ofdataargsobject Collection arguments
Returns Collection Returns a new collection with pagination configured
PaginationFactory.type
Types of pagination API
Properties
Entity
Extends AbstractModel
Entity class to handle ORM to a datasource</br/> Note: Datasource property is required
Parameters
attributesattributes Any attributes to prefill the modeloptionsobject Any options to pass (optional, default{})args...any
initialize
The query to use for the query - defaults to "id" selection
Parameters
options
Properties
queryobject The query string to use for selection
initialize
Parameters
options
Properties
initialize
Parameters
options
Properties
collectionstring The collection for the datasource (if applicable)
initialize
Initialize the model with needed wiring
Parameters
optionsobject Any options to pass
init
Custom init method for the model (called at inititlize)
Parameters
optionsobject Any options to pass
sync
Parameters
methodoptions
Properties
datasourceAugmented.Service.DataSource Datasource instance
sync
Sync method to handle datasource functions for the model
Parameters
fetch
Fetch the entity
Parameters
optionsobject Any options to pass
save
Save the entity
Parameters
optionsobject Any options to pass
update
Update the entity
Parameters
optionsobject Any options to pass
destroy
Destroy the entity
Parameters
optionsobject Any options to pass
Resource
Extends AbstractModel
Resource class to handle REST Note: URI property is required
Parameters
attributesattributes Any attributes to prefill the modeloptionsobject Any options to pass (optional, default{})args...any
initialize
Parameters
options
Properties
securestring The secure flag
initialize
Parameters
options
Properties
uristring The uri for the REST Service
initialize
Initialize the model with needed wiring
Parameters
optionsobject Any options to pass
init
Custom init method for the model (called at inititlize)
Parameters
optionsobject Any options to pass
fetch
Fetch the Resource
Parameters
optionsobject Any options to pass
sync
Sync method to handle REST functions for the model