Documentation ¶
Overview ¶
Deprecated: Use postgresql packet instead.
Index ¶
- func NewPostgresDatabase(URI string) (dbs database.IDatabase, err error)
- func NewPostgresDatabaseWithMessageBus(URI string, bus messaging.IMessageBus) (dbs database.IDatabase, err error)
- func NewPostgresStore(URI string) (dbs database.IDatastore, err error)
- type PostgresDatabase
- func (dbs *PostgresDatabase) BulkDelete(factory EntityFactory, entityIDs []string, keys ...string) (affected int64, err error)
- func (dbs *PostgresDatabase) BulkInsert(entities []Entity) (affected int64, err error)
- func (dbs *PostgresDatabase) BulkSetFields(factory EntityFactory, field string, values map[string]any, keys ...string) (affected int64, error error)
- func (dbs *PostgresDatabase) BulkUpdate(entities []Entity) (affected int64, err error)
- func (dbs *PostgresDatabase) BulkUpsert(entities []Entity) (affected int64, err error)
- func (dbs *PostgresDatabase) CloneDatabase() (database.IDatabase, error)
- func (dbs *PostgresDatabase) CloneDatastore() (database.IDatastore, error)
- func (dbs *PostgresDatabase) Close() error
- func (dbs *PostgresDatabase) CreateEntityIndex(factory EntityFactory, key string) (name string, err error)
- func (dbs *PostgresDatabase) CreateIndex(indexName string) (name string, err error)
- func (dbs *PostgresDatabase) Delete(factory EntityFactory, entityID string, keys ...string) (err error)
- func (dbs *PostgresDatabase) DropIndex(indexName string) (ack bool, err error)
- func (dbs *PostgresDatabase) DropTable(table string) (err error)
- func (dbs *PostgresDatabase) ExecuteDDL(ddl map[string][]string) (err error)
- func (dbs *PostgresDatabase) ExecuteQuery(source, sql string, args ...any) ([]Json, error)
- func (dbs *PostgresDatabase) ExecuteSQL(sql string, args ...any) (int64, error)
- func (dbs *PostgresDatabase) Exists(factory EntityFactory, entityID string, keys ...string) (result bool, err error)
- func (dbs *PostgresDatabase) Get(factory EntityFactory, entityID string, keys ...string) (result Entity, err error)
- func (dbs *PostgresDatabase) IndexExists(indexName string) (exists bool)
- func (dbs *PostgresDatabase) Insert(entity Entity) (added Entity, err error)
- func (dbs *PostgresDatabase) List(factory EntityFactory, entityIDs []string, keys ...string) (list []Entity, err error)
- func (dbs *PostgresDatabase) ListIndices(pattern string) (map[string]int, error)
- func (dbs *PostgresDatabase) Ping(retries uint, intervalInSeconds uint) error
- func (dbs *PostgresDatabase) PurgeTable(table string) (err error)
- func (dbs *PostgresDatabase) Query(factory EntityFactory) database.IQuery
- func (dbs *PostgresDatabase) SetField(factory EntityFactory, entityID string, field string, value any, ...) (err error)
- func (dbs *PostgresDatabase) SetFields(factory EntityFactory, entityID string, fields map[string]any, keys ...string) (err error)
- func (dbs *PostgresDatabase) Update(entity Entity) (updated Entity, err error)
- func (dbs *PostgresDatabase) Upsert(entity Entity) (updated Entity, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPostgresDatabase ¶
NewPostgresDatabase factory method for database
param: URI - represents the database connection string in the format of: postgresql://user:password@host:port/database_name?application_name return: IDatabase instance, error
func NewPostgresDatabaseWithMessageBus ¶
func NewPostgresDatabaseWithMessageBus(URI string, bus messaging.IMessageBus) (dbs database.IDatabase, err error)
NewPostgresDatabaseWithMessageBus factory method for database with injected message bus
param: URI - represents the database connection string in the format of: postgresql://user:password@host:port/database_name?application_name return: IDatabase instance, error
func NewPostgresStore ¶
func NewPostgresStore(URI string) (dbs database.IDatastore, err error)
NewPostgresStore factory method for datastore
param: URI - represents the database connection string in the format of: postgresql://user:password@host:port/database_name?application_name return: IDatabase instance, error
Types ¶
type PostgresDatabase ¶
type PostgresDatabase struct {
// contains filtered or unexported fields
}
func (*PostgresDatabase) BulkDelete ¶
func (dbs *PostgresDatabase) BulkDelete(factory EntityFactory, entityIDs []string, keys ...string) (affected int64, err error)
BulkDelete Delete multiple entities from the database in a single transaction (all must be of the same type)
param: factory - Entity factory param: entityIDs - List of entities IDs to delete param: keys - Sharding key(s) (for sharded entities and multi-tenant support) return: Number of deleted entities, error
func (*PostgresDatabase) BulkInsert ¶
func (dbs *PostgresDatabase) BulkInsert(entities []Entity) (affected int64, err error)
BulkInsert Insert multiple entities to database in a single transaction (all must be of the same type)
param: entities - List of entities to insert return: Number of inserted entities, error
func (*PostgresDatabase) BulkSetFields ¶
func (dbs *PostgresDatabase) BulkSetFields(factory EntityFactory, field string, values map[string]any, keys ...string) (affected int64, error error)
BulkSetFields Update specific field of multiple entities in a single transaction (eliminates the need to fetch - change - update)
param: factory - Entity factory param: field - The field name to update param: values - The map of entity Id to field value param: keys - Sharding key(s) (for sharded entities and multi-tenant support) return: Number of updated entities, error
func (*PostgresDatabase) BulkUpdate ¶
func (dbs *PostgresDatabase) BulkUpdate(entities []Entity) (affected int64, err error)
BulkUpdate Update multiple entities to database in a single transaction (all must be of the same type)
param: entities - List of entities to update return: Number of updated entities, error
func (*PostgresDatabase) BulkUpsert ¶
func (dbs *PostgresDatabase) BulkUpsert(entities []Entity) (affected int64, err error)
BulkUpsert Upsert multiple entities to database in a single transaction (all must be of the same type)
param: entities - List of entities to upsert return: Number of updated entities, error
func (*PostgresDatabase) CloneDatabase ¶
func (dbs *PostgresDatabase) CloneDatabase() (database.IDatabase, error)
CloneDatabase Returns a clone (copy) of the database instance
func (*PostgresDatabase) CloneDatastore ¶
func (dbs *PostgresDatabase) CloneDatastore() (database.IDatastore, error)
CloneDatastore Returns a clone (copy) of the database instance
func (*PostgresDatabase) Close ¶
func (dbs *PostgresDatabase) Close() error
Close DB and free resources
func (*PostgresDatabase) CreateEntityIndex ¶
func (dbs *PostgresDatabase) CreateEntityIndex(factory EntityFactory, key string) (name string, err error)
CreateEntityIndex creates an index of entity and add entity field mapping
func (*PostgresDatabase) CreateIndex ¶
func (dbs *PostgresDatabase) CreateIndex(indexName string) (name string, err error)
CreateIndex creates an index (without mapping)
func (*PostgresDatabase) Delete ¶
func (dbs *PostgresDatabase) Delete(factory EntityFactory, entityID string, keys ...string) (err error)
Delete entity
param: factory - Entity factory param: entityID - Entity ID to delete param: keys - Sharding key(s) (for sharded entities and multi-tenant support) return: error
func (*PostgresDatabase) DropIndex ¶
func (dbs *PostgresDatabase) DropIndex(indexName string) (ack bool, err error)
DropIndex drops an index
func (*PostgresDatabase) DropTable ¶
func (dbs *PostgresDatabase) DropTable(table string) (err error)
DropTable Drop table and indexes
param: table - Table name to drop return: error
func (*PostgresDatabase) ExecuteDDL ¶
func (dbs *PostgresDatabase) ExecuteDDL(ddl map[string][]string) (err error)
ExecuteDDL create table and indexes
param: ddl - The ddl parameter is a map of strings (table names) to array of strings (list of fields to index) return: error
func (*PostgresDatabase) ExecuteQuery ¶
func (dbs *PostgresDatabase) ExecuteQuery(source, sql string, args ...any) ([]Json, error)
ExecuteQuery Execute native SQL query
func (*PostgresDatabase) ExecuteSQL ¶
func (dbs *PostgresDatabase) ExecuteSQL(sql string, args ...any) (int64, error)
ExecuteSQL Execute SQL command
param: sql - The SQL command to execute param: args - Statement arguments return: Number of affected records, error
func (*PostgresDatabase) Exists ¶
func (dbs *PostgresDatabase) Exists(factory EntityFactory, entityID string, keys ...string) (result bool, err error)
Exists Check if entity exists by ID
param: factory - Entity factory param: entityID - Entity id param: keys - Sharding key(s) (for sharded entities and multi-tenant support) return: bool, error
func (*PostgresDatabase) Get ¶
func (dbs *PostgresDatabase) Get(factory EntityFactory, entityID string, keys ...string) (result Entity, err error)
Get a single entity by ID
param: factory - Entity factory param: entityID - Entity id param: keys - Sharding key(s) (for sharded entities and multi-tenant support) return: Entity, error
func (*PostgresDatabase) IndexExists ¶
func (dbs *PostgresDatabase) IndexExists(indexName string) (exists bool)
IndexExists tests if index exists
func (*PostgresDatabase) Insert ¶
func (dbs *PostgresDatabase) Insert(entity Entity) (added Entity, err error)
Insert new entity
param: entity - The entity to insert return: Inserted Entity, error
func (*PostgresDatabase) List ¶
func (dbs *PostgresDatabase) List(factory EntityFactory, entityIDs []string, keys ...string) (list []Entity, err error)
List Get list of entities by IDs
param: factory - Entity factory param: entityIDs - List of Entity IDs param: keys - Sharding key(s) (for sharded entities and multi-tenant support) return: []Entity, error
func (*PostgresDatabase) ListIndices ¶
func (dbs *PostgresDatabase) ListIndices(pattern string) (map[string]int, error)
ListIndices returns a list of all indices matching the pattern
func (*PostgresDatabase) Ping ¶
func (dbs *PostgresDatabase) Ping(retries uint, intervalInSeconds uint) error
Ping Test database connectivity
param: retries - how many retries are required (max 10) param: intervalInSeconds - time interval (in seconds) between retries (max 60)
func (*PostgresDatabase) PurgeTable ¶
func (dbs *PostgresDatabase) PurgeTable(table string) (err error)
PurgeTable Fast delete table content (truncate)
param: table - Table name to purge return: error
func (*PostgresDatabase) Query ¶
func (dbs *PostgresDatabase) Query(factory EntityFactory) database.IQuery
Query Helper method to construct query
param: factory - Entity factory return: Query object
func (*PostgresDatabase) SetField ¶
func (dbs *PostgresDatabase) SetField(factory EntityFactory, entityID string, field string, value any, keys ...string) (err error)
SetField Update a single field of the document in a single transaction
param: factory - Entity factory param: entityID - The entity ID to update the field param: field - The field name to update param: value - The field value to update param: keys - Sharding key(s) (for sharded entities and multi-tenant support) return: error
func (*PostgresDatabase) SetFields ¶
func (dbs *PostgresDatabase) SetFields(factory EntityFactory, entityID string, fields map[string]any, keys ...string) (err error)
SetFields Update some fields of the document in a single transaction
param: factory - Entity factory param: entityID - The entity ID to update the field param: fields - A map of field-value pairs to update param: keys - Sharding key(s) (for sharded entities and multi-tenant support) return: error
func (*PostgresDatabase) Update ¶
func (dbs *PostgresDatabase) Update(entity Entity) (updated Entity, err error)
Update existing entity
param: entity - The entity to update return: Updated Entity, error
func (*PostgresDatabase) Upsert ¶
func (dbs *PostgresDatabase) Upsert(entity Entity) (updated Entity, err error)
Upsert Update entity or insert it if it does not exist
param: entity - The entity to update return: Updated Entity, error