service-entity-models
v3.0.1
Published
The Augmented.js Next Service - Entity Models Module.
Downloads
7
Maintainers
Readme
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
models
options
(optional, default{}
)
uri
Collection name for us in a datasource or an identifier
Properties
name
string The name of the collection
uri
Properties
uri
string 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
options
object Any options to pass
save
Save the entity
Parameters
options
object Any options to pass
update
Update the entity
Parameters
options
object Any options to pass
destroy
Destroy the entity
Parameters
options
object Any options to pass
EntityCollection
Extends AbstractCollection
Collection class to handle ORM to a datasource</br/> Note: Datasource property is required
Parameters
models
options
uri
Collection name for us in a datasource or an identifier
Properties
name
string The name of the collection
uri
The query to use for the query - defaults to "id" selection
uri
Properties
uri
string 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
options
object Any options to pass
init
Custom init method for the model (called at initialize)
Parameters
options
object Any options to pass
setDatasource
Parameters
datasource
Properties
datasource
Augmented.Service.DataSource Datasource instance
setDatasource
Set the datasource for the Collection
Parameters
datasource
object The datasource object
sync
Sync method to handle datasource functions for the Collection
Parameters
fetch
Fetch the entity
Parameters
options
object Any options to pass
save
Save the entity
Parameters
options
object Any options to pass
update
Update the entity
Parameters
options
object Any options to pass
destroy
Destroy the entity
Parameters
options
object Any options to pass
setDataSourceCollection
Set the DataSource Collection
Parameters
name
string 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
models
options
setPageSize
Sets the number of items in a page
Parameters
size
number Number of items in each page
setCurrentPage
Sets the current page
Parameters
page
number Current page in collection
fetch
Fetch the entity
Parameters
options
object Any options to pass
nextPage
Moves to the next page
previousPage
Moves to the previous page
goToPage
Goes to page
Parameters
page
number 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
Collection
PAGINATION_API The collection class to enrichapiType
PAGINATION_API The API type to return an instance ofdata
args
object 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
attributes
attributes Any attributes to prefill the modeloptions
object Any options to pass (optional, default{}
)args
...any
initialize
The query to use for the query - defaults to "id" selection
Parameters
options
Properties
query
object The query string to use for selection
initialize
Parameters
options
Properties
initialize
Parameters
options
Properties
collection
string The collection for the datasource (if applicable)
initialize
Initialize the model with needed wiring
Parameters
options
object Any options to pass
init
Custom init method for the model (called at inititlize)
Parameters
options
object Any options to pass
sync
Parameters
method
options
Properties
datasource
Augmented.Service.DataSource Datasource instance
sync
Sync method to handle datasource functions for the model
Parameters
fetch
Fetch the entity
Parameters
options
object Any options to pass
save
Save the entity
Parameters
options
object Any options to pass
update
Update the entity
Parameters
options
object Any options to pass
destroy
Destroy the entity
Parameters
options
object Any options to pass
Resource
Extends AbstractModel
Resource class to handle REST Note: URI property is required
Parameters
attributes
attributes Any attributes to prefill the modeloptions
object Any options to pass (optional, default{}
)args
...any
initialize
Parameters
options
Properties
secure
string The secure flag
initialize
Parameters
options
Properties
uri
string The uri for the REST Service
initialize
Initialize the model with needed wiring
Parameters
options
object Any options to pass
init
Custom init method for the model (called at inititlize)
Parameters
options
object Any options to pass
fetch
Fetch the Resource
Parameters
options
object Any options to pass
sync
Sync method to handle REST functions for the model