Collection of event subscribers, by their events.
The original row fetched from the database.
Cache of relation instances by property accessor.
This is used by the @Relation()
decorator to cache Relation instances.
Relations that should be eager-loaded by default.
Optionally, the timestamp field set on creation.
Optionally, the timestamp field set op update.
Array of additional fields on the class that should be included in the object serializations.
The name of the connection this model should run through.
The name of the column that uniquely identifies this model.
Array of fields on the class that should be excluded from the object serializations.
If false (default), the primary key will be excluded from INSERTs.
The name of the table this model is stored in.
If true, the CREATED_AT and UPDATED_AT columns will be automatically set.
The global application instance.
Get a wrapped function that compares whether the given model field on the current instance differs from the originally fetched value.
Used to filter for dirty fields.
Get an array of all instances of this model.
Get the global Application.
Similar to assumeFromSource, but instead of mapping database fields to model
properties, this function assumes the object
contains a mapping of model properties
to the values of those properties.
Only properties with @Field()
annotations will be set.
Given a row from the database, set the properties on this model that correspond to fields on that database.
The row
maps database fields to values, and the values are set for the properties
that they correspond to based on the model's @Field()
annotations.
Create the inverse of a one-to-many relation. Should be called from a method on the model:
Create the inverse of a one-to-one relation. Should be called from a method on the model:
Initialize the model's properties from the given values and do any other initial setup.
values
can optionally be an object mapping model properties to the values of those
properties. Only properties with @Field()
annotations will be set.
Build an object mapping database fields to the values that should be inserted for them.
Build an EventSubscription object for the subscriber of the given ID.
Get the global Container.
Count all instances of this model in the database.
Delete the current model from the database, if it exists.
Get a query row mapping database columns to values for properties on this
model that (1) have @Field()
annotations and (2) have been modified since
the record was fetched from the database or created.
Returns true if this instance's record has been persisted into the database.
Fetch a fresh instance of this record from the database.
This returns a NEW instance of the SAME record by matching on the primary key. It does NOT change the current instance of the record.
Get the method with the given name from this class, bound to this class.
function
Returns an array of MODEL fields that have been modified since this record was fetched from the database or created.
Returns a list of DATABASE fields that have been loaded for the current instance.
Get an object of the database field => value mapping that was originally fetched from the database. Excludes changes to model properties.
Get the relation instance returned by a method on this model.
Create a new one-to-one relation instance. Should be called from a method on the model:
Create a new one-to-one relation instance. Should be called from a method on the model:
Returns true if the current model has a scope with the given identifier.
Called when the model is instantiated. Use for any setup of events, &c.
Returns true if the other
model refers to the same database record as this instance.
This is done by comparing the qualified primary keys.
Returns true if none of the fields on this model have been modified since they were fetched from the database (and all exist in the database).
Only fields with @Field()
annotations are checked.
Returns true if any of the fields on this model have been modified since they were fetched from the database (or ones that were never saved to the database).
Only fields with @Field()
annotations are checked.
Inverse of is()
.
Get the value of the primary key of this model, if it exists.
Get the unqualified name of the column corresponding to the primary key of this model.
Call the make()
method on the global container.
Register a scope on the model with a specific name.
Return an object of only the given properties on this model.
Populates an instance of the model with the same database fields that are set on this model, with the exclusion of the primary key.
Useful for inserting copies of records.
Given the name of a column, return the qualified name of the column as it could appear in a query.
Return the qualified name of the column corresponding to the model's primary key.
Get a new query builder that yields instances of this model, pre-configured with this model's QuerySource, connection, and fields.
Re-load the currently-loaded database fields from the table.
Overwrites any un-persisted changes in the current instance.
Persist the model into the database. If the model already exists, perform an update on its fields. Otherwise, insert a new row with its fields.
Passing the withoutTimestamps
will prevent the configured CREATED_AT/UPDATED_AT
timestamps from being updated.
Register a scope on the model.
Sets a property on this
to the value of a given property in object
.
Get normalized values of the configured CREATED_AT/UPDATED_AT fields for this model.
Cast the model to an JSON string object.
Only fields with @Field()
annotations are included.
Cast this model to a simple object mapping model fields to their values.
Only fields with @Field()
annotations are included.
Cast the model to the base QueryRow object. The resultant object maps DATABASE fields to values, NOT MODEL fields to values.
Only fields with @Field()
annotations will be included.
Updates the timestamps for this model, if they are configured.
If the model doesn't yet exist, set the CREATED_AT date. Always sets the UPDATED_AT date.
Returns true if the given field has changed since this model was fetched from the database, or if the given field never existed in the database.
Get the name of the connection where this model's table is found.
Get the database connection instance for this model's connection.
Given the name of a property on the model with a @Field()
annotation,
return the unqualified name of the database column it corresponds to.
Given the name of a column, return the qualified name of the column as it could appear in a query.
Return the qualified name of the column corresponding to the model's primary key.
Get a new query builder that yields instances of this model, pre-configured with this model's QuerySource, connection, and fields.
Get the QuerySource object for this model as it should be applied to query builders.
This sets the alias for the model table equal to the table name itself, so it can be referenced explicitly in queries if necessary.
Get the table name for this model.
extollo (v. latin) - to lift up, to elevate
Extollo is a free & libre application framework in TypeScript.
Base for classes that are mapped to tables in a database.