-
modelName -
data
Creates a new record for a given model using supplied attributes hash
Returns:
-
modelName
Finds all records for a given model. Use query when you need more control over
what records are returned.
Parameters:
-
modelNameString
Returns:
-
modelName -
id
Retrieves a single record for the given model by given id
Returns:
-
modelName -
options
Finds records of a given model using options.
Options is an {Object} with the following properties:
include - used to include related model records
store.query(Post, {include: 'comments,author'})
fields - used to specify desired attribute fields to be returned in result objects
store.query(Post, {fields: {posts: 'title,description'}})
To restrict fields from included relationship models
store.query(Post, {fields: {posts: 'title', comments: 'comment'}})
sort - used to sort results by its attributes
store.query(Post, {sort: 'title'})
To specify sorting by multiple columns, separate by comma
store.query(Post, {sort: 'title,description'})
Sort is ascending by default, use "-" to indicate descending
store.query(Post, {sort: '-title'})
page - used to paginate results
store.query(Post, {page: {number: 1, size: 20}})
filter - used to refine desired results by specified criteria
store.query(Post, {filter: {title: 'my title'}})
filter also supports a number of operators prefixed with a $ character
$or- SQL OR$eq- SQL =$gt- SQL >$gte- SQL >=$lt- SQL <$lte- SQL <=$ne- SQL !=$not- SQL NOT$between- SQL BETWEEN$notbetween- SQL NOT BETWEEN$in- SQL IN$notinSQL NOT IN$likeSQL LIKE$notlikeSQL NOT LIKE$ilike- SQL NOT ILIKE$overlap- SQL &&$contains- SQL @>$contained- SQL <@
store.query(Post, {filter: {title: {$like: '%my title%'}}})
$or is a slightly special case. It takes an array of objects to 'Or' together
store.query(Post, {filter: {
$or: [
{id: {$lt: 10}},
{id: {$in: [20, 21, 22]}}
]
})
Returns:
-
modelName -
options
Similar to query except that only a single record is returned