serverpod_database library
Classes
-
AnyExpression<
T> - A database expression that returns all rows where any of the related rows match the filtering criteria.
- BulkData
- BulkQueryColumnDescription
- BulkQueryResult
-
Column<
T> - Abstract class representing a database Column. Subclassed by the different supported column types such as ColumnInt or ColumnString.
- ColumnBigInt
- A Column holding BigInt.
- ColumnBit
-
A Column holding a
Bitvector from pgvector. - ColumnBool
- A Column holding an bool.
- ColumnByteData
- A Column holding ByteData.
-
ColumnComparable<
T> - A Column whose values can be compared equal or unequal to other values. Attends full specification of default PG comparison operations: https://www.postgresql.org/docs/current/functions-comparison.html#FUNCTIONS-COMPARISON-OP-TABLE
- ColumnCount
- A Column holding a count of rows.
- ColumnDateTime
- A Column holding an DateTime. In the database it is stored as a timestamp without time zone.
- ColumnDefinition
- The definition of a (desired) column in the database.
- ColumnDouble
- A Column holding an double.
- ColumnDuration
- A Column holding Duration.
-
ColumnEnum<
E extends Enum> - A Column holding an enum.
-
ColumnEnumExtended<
E extends Enum> - Intended for internal use only
-
ColumnExpression<
T> - Database expression for a column.
- ColumnHalfVector
-
A Column holding a
HalfVectorfrom pgvector. - ColumnInt
- A Column holding an int.
- ColumnMigration
-
ColumnSerializable<
T> -
A Column holding an
SerializableModel. The entity will be stored in the database as a json column. - ColumnSparseVector
-
A Column holding a
SparseVectorfrom pgvector. - ColumnString
- A Column holding an String.
- ColumnUri
- A Column holding Uri.
- ColumnUuid
-
A Column holding
UuidValue. -
ColumnValue<
T, V> - Represents a column-value pair for database updates.
- ColumnVector
-
A Column holding a
Vectorfrom pgvector. -
ColumnVectorDistance<
T> - A Column holding the result of a vector distance operation.
- Constant
- A constant Expression.
- Database
- Provides easy access to the database in relation to the current DatabaseSession.
- DatabaseAnalyzer
- Analyzes the structure of Databases.
- DatabaseBulkData
- Provides a way to export raw data from the database. The data is serialized using JSON. Primarily used for Serverpod Insights.
- DatabaseDefinition
- Defines the structure of the database used by Serverpod.
- DatabaseDefinitions
- Defines the current state of the database, including information about installed modules and migrations.
- DatabaseMigration
- DatabaseMigrationAction
- DatabaseMigrationVersionModel
- Represents a version of a database migration.
- DatabaseMigrationWarning
- DatabasePoolManager
- Abstract interface for database pool managers. Provides a unified interface for both any database dialect implementation.
- DatabaseProvider
- Abstract interface for database providers. Provides a unified interface for any database dialect implementation.
- DatabaseResult
- Database result.
- DatabaseResultRow
- Database result row.
- DatabaseResultSchema
- Database result schema.
- DatabaseResultSchemaColumn
- Database result schema column.
- DatabaseSession
- Interface for accessing the database.
- DatabaseUtil
- Provides utility functions for working with the Database.
- EscapedExpression
- A database expression that is escaped. This is used to escape values that are not expressions, such as strings and numbers.
-
EveryExpression<
T> - A database expression that returns all rows where all of the related rows match the filtering criteria.
-
Expression<
T> - A database Expression.
- FileSystemMigrationArtifactStore
- Stores migration artifacts using the current file-system based format.
- Filter
- FilterConstraint
- ForeignKeyDefinition
- Represents a foreign key.
- HnswIndexQueryOptions
- Query options for the HNSW index.
- Include
- The base include class, should not be used directly.
- IncludeList
- Defines what tables to join when querying a table.
- IncludeObject
- Defines what tables to join when querying a table.
- IndexDefinition
- The definition of a (desired) index in the database.
- IndexElementDefinition
- Defines an element of an index.
- IvfflatIndexQueryOptions
- Query options for the IVFFLAT index.
-
ManyRelation<
T extends Table> - Many relation field between two tables.
- MapRuntimeParameters
- Runtime parameters that can be built from a map of options.
- MigrationArtifactStore
- Persists and loads migration artifacts from a storage implementation.
- MigrationManager
- The migration manager handles migrations of the database.
- MigrationVersionArtifacts
- A semantic representation of a migration version and its persisted artifacts.
-
NoneExpression<
T> - A database expression that returns all rows where none of the related rows match the filtering criteria.
- NotExpression
- A database expression to invert the result of another expression.
- Order
- Defines how to order a database column.
- PgErrorCode
- A class containing constants for PostgreSQL error codes.
- Protocol
- QueryParameters
- Provides parameters for direct database queries
- QueryParametersNamed
- Named parameters for direct database queries.
- QueryParametersPositional
- Positional parameters for direct database queries
- RepairMigration
- A migration used to repair the database back to a specific migration version.
- RuntimeParameters
- Base class for runtime parameters group to apply to the database.
- RuntimeParametersBuilder
-
Builder class for runtime parameters that provides discoverable factory methods.
This enables the callback pattern: setRuntimeParameters((params) =>
...) - Savepoint
- A savepoint in a transaction.
- SearchPathsConfig
- Search path configuration for database schema resolution.
- SerializationManagerServer
-
The
SerializationManageris responsible for creating objects from a serialization, but also for serializing objects. This class is typically overridden by generated code. SerializationManagerServer is an extension to also handle Tables. -
Table<
T_ID> - Represents a database table.
- TableDefinition
- The definition of a (desired) table in the database.
- TableMigration
-
TableRow<
T_ID> - Holds data corresponding to a row in the database. Concrete classes are typically generated. Instances of TableRow can also be serialized and either passed to clients or cached.
- Transaction
- Holds the state of a running database transaction.
- TransactionSettings
- Settings for a transaction.
- TwoPartExpression
- A database expression with two parts.
-
UpdateTable<
T extends Table> - Base class for database table update operations.
- ValueEncoder
- Interface for value encoders.
-
VectorDistanceExpression<
T> - Vector distance expression for use with pgvector.
- VectorIndexQueryOptions
- Query options for vector indexes.
Enums
- ColumnType
-
All the types, that are possible for columns.
Contains all the values of
TypeDefinition.databaseType - DatabaseMigrationActionType
- DatabaseMigrationWarningType
- EnumSerialization
- FilterConstraintType
- ForeignKeyAction
- Describes how to react if the row a foreign key refers to changes / is deleted.
- ForeignKeyMatchType
- Defines how a foreign key should be matched.
- IndexElementDefinitionType
- Used to specify how the definition of an IndexElementDefinition should be interpreted.
- IsolationLevel
- Isolation levels for transactions.
- IterativeScan
- Automatically scan more of the index until enough results are found.
- LockBehavior
- Specifies the behavior when a lock cannot be immediately acquired.
- LockMode
- Specifies the type of row-level lock to acquire.
- VectorDistanceFunction
- Vector distance functions exposed by pgvector.
- VectorIndexType
- Allowed types for vector indexes.
Extensions
- ColumnComparisons on ColumnDefinition
- Comparison methods for ColumnDefinition.
- DatabaseConstructor on Database
- Extension to only expose the Database constructor internally within the package.
- DatabaseDefinitionUtils on DatabaseDefinition
- Utility methods for DatabaseDefinition.
- FilterConstraintGenerator on FilterConstraint
- SQL code generation methods for FilterConstraint.
- FilterGenerator on Filter
- SQL code generation methods for Filter.
- ForeignKeyComparisons on ForeignKeyDefinition
- Comparison methods for ForeignKeyDefinition.
- IdColumnIterable on Iterable
- An extension on iterable for Id columns.
- IndexComparisons on IndexDefinition
- Comparison methods for IndexDefinition.
- IndexElementDefinitionComparison on IndexElementDefinition
- Comparison methods for IndexElementDefinition.
- TableComparisons on TableDefinition
- Comparison methods for TableDefinition.
- TableDefinitionUtils on TableDefinition
- Utility methods for TableDefinition.
- TableRowDatabaseJsonExtension on TableRow
- Extension on a TableRow to ensure database serialization matches the expected naming of the column in the database
- VectorDatabase on Database
- Extension to add vector specific utilities to the database.
Constants
- currentSchemaVersion → const int
- The current schema version of the database definition.
- defaultBooleanFalse → const String
-
The identifier for the default value to boolean
false. - defaultBooleanTrue → const String
-
The identifier for the default value to boolean
true. - defaultDateTimeValueNow → const String
- The identifier for the default value to the current timestamp.
- defaultIntSerial → const String
- Int for the default primary key type.
- defaultPrimaryKeyName → const String
- The name of the default primary key column.
- defaultUuidValueRandom → const String
- The identifier for the default value to a random UUID v4.
- defaultUuidValueRandomV7 → const String
- The identifier for the default value to a random UUID v7.
Functions
-
createRelationTable<
T> ({required String relationFieldName, required Column field, required Column foreignField, TableRelation? tableRelation, required T createTable(TableRelation foreignTableRelation)}) → T -
Creates a new Table containing
TableRelationwith information about how the tables are joined. -
equalsType<
T_ID, Y> () → bool -
Checks if the type
Tis equal to typeY(nullable or non-nullable).
Typedefs
-
ColumnSelections<
T extends Table> = List< Column> Function(T) - A function that returns a Column for a Table.
-
ColumnValueListBuilder<
T extends UpdateTable< Table> > = List<ColumnValue> Function(T) - A function that returns a list of ColumnValues for a UpdateTable.
-
LogQueryFunction
= Future<
void> Function({required Duration duration, required String? error, required int? numRowsAffected, required String query, required StackTrace stackTrace}) - Function type for logging a query.
-
LogWarningFunction
= Future<
void> Function(String message) - Function type for logging a warning during the execution of a query.
- MigrationWarningWriter = void Function(String message)
- A function that writes a warning message.
-
OrderByBuilder<
T extends Table> = Column Function(T) - A function that returns a Column for a Table to be used with order by
-
OrderByListBuilder<
T extends Table> = List< Order> Function(T) - A function that returns a list of Order for a Table to be used with order by list.
-
RuntimeParametersListBuilder
= List<
RuntimeParameters> Function(RuntimeParametersBuilder params) - A function that returns a list of RuntimeParameters for configuring database runtime parameters.
-
TransactionFunction<
R> = Future< R> Function(Transaction transaction) - A function performing a transaction, passed to the transaction method.
-
WhereExpressionBuilder<
T extends Table> = Expression Function(T) - A function that returns an Expression for a Table to be used with where clauses.
Exceptions / Errors
- BulkDataException
- DatabaseDeleteRowException
- Exception thrown when a delete row operation fails.
- DatabaseException
- Exception thrown when an error occurs in the database.
- DatabaseInsertRowException
- Exception thrown when an insert row operation fails.
- DatabaseQueryException
- Exception thrown when an exception occurs during a database query.
- DatabaseUpdateRowException
- Exception thrown when an update row operation fails.
- RollbackToSavepointFailedException
- Exception thrown when an attempt to rollback to a savepoint in response to clean up after another exception fails.