Database.repository

New in package 166

Syntax

Database.repository(type_name)

Description

A repository is an enumerable object used to query and modify database entities.

Methods

See also Enumerable Object Methods.

Crud

Method Description
[create]([initial_data]) Creates a new entity.
[add]([initial_data])
[add](entity)
Adds the new entity to the repository. The entity will be added to the database on [Database.saveChanges()].
[get](id[, ifNotExists]) Returns an entity by entity id. Throws an exception if no such entity has been found and ifNotExists parameter has not been specified.
[delete](entity) Deletes the entity from the repository. The entity will be deleted from the database on [Database.saveChanges()].

Queries

See Database.query

Projection

See Database.query

Aggregate functions

See Database.query

Set functions

See Database.query

Model

Method Description
[addReference]('property', referenced-repository, 'referenceId', options) Extends all the repository entties with entity.property which references a referenced-repository entity defined by the entity.referenceId.
[addCollection]('property', query, options) Extends all the repository entites with entity.property which represents a collection of entities defined by the query.

Data

[$schema](options) Specifies which data to send to the client and to which fields to apply it when it comes back.
[getData]([schema])  
[setData](data [, schema])  

Properties

Property Description
type Type information
repository Repository object

Events

Method Description
[on].event( function event( entity ) { ... })
[on]('event', function event( entity ) { ... })
Adds a listener for a repository event.
Event Description
[objectLoaded] Fired when an entity is created or loaded from the database.

Examples

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.