Timestamp when the category was created
Automatically set on insertion.
User who created the category
Many relation to the User
entity.
Unique identifier for the category
Auto-generated primary key.
Name of the survey category
A short, unique label used to classify surveys.
Surveys belonging to this category
One-to-many relation to the Survey
entity.
Timestamp when the category was last updated
Automatically updated on change.
Static
targetReturns object that is managed by this repository. If this repository manages entity from schema, then it returns a name of that schema instead.
Static
averageStatic
clearStatic
countStatic
countStatic
createCreates a new entity instance.
Creates a new entities and copies all entity properties from given objects into their new entities. Note that it copies only properties that present in entity schema.
Creates a new entity instance and copies all entity properties from this object into a new entity. Note that it copies only properties that present in entity schema.
Static
createStatic
deleteDeletes entities by a given criteria. Unlike remove method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient DELETE query. Does not check if entity exist in the database.
Static
existsStatic
existsStatic
findStatic
findStatic
findStatic
findStatic
findFinds entities by ids. Optionally find options can be applied.
use findBy
method instead in conjunction with In
operator, for example:
.findBy({ id: In([1, 2, 3]) })
Static
findStatic
findStatic
findFinds first entity that matches given options.
use findOneBy
method instead in conjunction with In
operator, for example:
.findOneBy({ id: 1 // where "id" is your primary column name })
Static
findStatic
findStatic
getStatic
getStatic
hasStatic
insertInserts a given entity into the database. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient INSERT query. Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
Static
maximumStatic
mergeStatic
minimumStatic
preloadCreates a new entity from the given plain javascript object. If entity already exist in the database, then it loads it (and everything related to it), replaces all values with the new ones from the given object and returns this new entity. This new entity is actually a loaded from the db entity with all properties replaced from the new object.
Note that given entity-like object must have an entity id / primary key to find entity by. Returns undefined if entity with given id was not found.
Static
queryExecutes a raw SQL query and returns a raw database results. Raw query execution is supported only by relational databases (MongoDB is not supported).
Optional
parameters: any[]Static
removeStatic
saveSaves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.
Saves a given entity in the database. If entity does not exist in the database then inserts, otherwise updates.
Static
softRecords the delete date of all given entities.
Records the delete date of a given entity.
Static
sumStatic
updateUpdates entity partially. Entity can be found by a given conditions. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient UPDATE query. Does not check if entity exist in the database.
Static
upsertInserts a given entity into the database, unless a unique constraint conflicts then updates the entity Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.
Static
use
Category Entity
Description
Represents a category for organizing surveys. Each category is uniquely named and can contain multiple surveys. It is created by a user and timestamps are automatically handled.
Param: name
is the entity's name in the database (
category
).This class defines the structure of the category entity in the database:
id
: unique identifier for the category.name
: unique name for the category.user
: the user who created this category.surveys
: surveys that belong to this category.createdAt
: timestamp of when the category was created.updatedAt
: timestamp of the last update.Example
Decorators used:
@Entity()
: defines the table.@PrimaryGeneratedColumn()
: auto-generates the primary key.@Column()
: maps properties to columns.@OneToOne()
/@OneToMany()
: defines relations.@ManyToOne()
: defines the relations toCategory
andUser
.@Field()
: exposes fields in GraphQL schema.