persistence

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateObjectIdIfNotExists

func GenerateObjectIdIfNotExists[T any](obj any) T

func GenerateObjectMapIdIfNotExists

func GenerateObjectMapIdIfNotExists(objectMap map[string]any)

func GetObjectId

func GetObjectId[K any](obj any) (id K)

func ItemsToAnySlice

func ItemsToAnySlice[T any](items []T) []any

Types

type IPostgresPersistenceOverrides

type IPostgresPersistenceOverrides[T any] interface {
	DefineSchema()
	ConvertFromPublic(item T) (map[string]any, error)
	ConvertToPublic(item pgx.Rows) (T, error)
	ConvertFromPublicPartial(item map[string]any) (map[string]any, error)
}

type IdentifiableJsonPostgresPersistence

type IdentifiableJsonPostgresPersistence[T any, K any] struct {
	*IdentifiablePostgresPersistence[T, K]
}

IdentifiableJsonPostgresPersistence is an abstract persistence component that stores data in PostgreSQL in JSON or JSONB fields and implements a number of CRUD operations over data items with unique ids. The data items must implement IIdentifiable interface.

The JSON table has only two fields: id and data.

In basic scenarios child classes shall only override getPageByFilter, getListByFilter or deleteByFilter operations with specific filter function. All other operations can be used out of the box.

In complex scenarios child classes can implement additional operations by accessing c._collection and c._model properties.

Configuration parameters

	- collection:                  (optional) PostgreSQL collection name
	- connection(s):
		- discovery_key:             (optional) a key to retrieve the connection from IDiscovery
		- host:                      host name or IP address
		- port:                      port number (default: 27017)
		- uri:                       resource URI or connection string with all parameters in it
	- credential(s):
		- store_key:                 (optional) a key to retrieve the credentials from ICredentialStore
		- username:                  (optional) user name
		- password:                  (optional) user password
	- options:
		- connect_timeout:      (optional) number of milliseconds to wait before timing out when connecting a new client (default: 0)
		- idle_timeout:         (optional) number of milliseconds a client must sit idle in the pool and not be checked out (default: 10000)
		- max_pool_size:        (optional) maximum number of clients the pool should contain (default: 10)

References
	- *:logger:*:*:1.0           (optional) ILogger components to pass log messages components to pass log messages
	- *:discovery:*:*:1.0        (optional) IDiscovery services
	- *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials

Example:
	type DummyJsonPostgresPersistence struct {
		*persist.IdentifiableJsonPostgresPersistence[fixtures.Dummy, string]
	}

	func NewDummyJsonPostgresPersistence() *DummyJsonPostgresPersistence {
		c := &DummyJsonPostgresPersistence{}
		c.IdentifiableJsonPostgresPersistence = persist.InheritIdentifiableJsonPostgresPersistence[fixtures.Dummy, string](c, "dummies_json")
		return c
	}

	func (c *DummyJsonPostgresPersistence) DefineSchema() {
		c.ClearSchema()
		c.IdentifiableJsonPostgresPersistence.DefineSchema()
		c.EnsureTable("", "")
		c.EnsureIndex(c.TableName+"_key", map[string]string{"(data->'key')": "1"}, map[string]string{"unique": "true"})
	}

	func (c *DummyJsonPostgresPersistence) GetPageByFilter(ctx context.Context, correlationId string,
		filter cdata.FilterParams, paging cdata.PagingParams) (page cdata.DataPage[fixtures.Dummy], err error) {

		key, ok := filter.GetAsNullableString("Key")
		filterObj := ""
		if ok && key != "" {
			filterObj += "data->key='" + key + "'"
		}

		return c.IdentifiableJsonPostgresPersistence.GetPageByFilter(ctx, correlationId,
			filterObj, paging,
			"", "",
		)
	}

	func (c *DummyJsonPostgresPersistence) GetCountByFilter(ctx context.Context, correlationId string,
		filter cdata.FilterParams) (count int64, err error) {

		filterObj := ""
		if key, ok := filter.GetAsNullableString("Key"); ok && key != "" {
			filterObj += "data->key='" + key + "'"
		}

		return c.IdentifiableJsonPostgresPersistence.GetCountByFilter(ctx, correlationId, filterObj)
	}

	func (c *DummyJsonPostgresPersistence) GetOneRandom(ctx context.Context, correlationId string) (item fixtures.Dummy, err error) {
		return c.IdentifiableJsonPostgresPersistence.GetOneRandom(ctx, correlationId, "")
	}

func InheritIdentifiableJsonPostgresPersistence

func InheritIdentifiableJsonPostgresPersistence[T any, K any](overrides IPostgresPersistenceOverrides[T], tableName string) *IdentifiableJsonPostgresPersistence[T, K]

InheritIdentifiableJsonPostgresPersistence creates a new instance of the persistence component.

Parameters:
	- overrides References to override virtual methods
	- tableName    (optional) a table name.

func (*IdentifiableJsonPostgresPersistence[T, K]) ConvertFromPublic

func (c *IdentifiableJsonPostgresPersistence[T, K]) ConvertFromPublic(value T) (map[string]any, error)

ConvertFromPublic convert object value from public to internal format.

	Parameters:
   - value     an object in public format to convert.

Returns converted object in internal format.

func (*IdentifiableJsonPostgresPersistence[T, K]) ConvertFromPublicPartial

func (c *IdentifiableJsonPostgresPersistence[T, K]) ConvertFromPublicPartial(value map[string]any) (map[string]any, error)

ConvertFromPublicPartial convert object value from public to internal format.

Parameters:
	- value     an object in public format to convert.
Returns: converted object in internal format.

func (*IdentifiableJsonPostgresPersistence[T, K]) ConvertToPublic

func (c *IdentifiableJsonPostgresPersistence[T, K]) ConvertToPublic(rows pgx.Rows) (T, error)

ConvertToPublic converts object value from internal to public format.

Parameters:
	- value an object in internal format to convert.
Returns: converted object in public format.

func (*IdentifiableJsonPostgresPersistence[T, K]) EnsureTable

func (c *IdentifiableJsonPostgresPersistence[T, K]) EnsureTable(idType string, dataType string)

EnsureTable Adds DML statement to automatically create JSON(B) table

	Parameters:
  - idType type of the id column (default: TEXT)
  - dataType type of the data column (default: JSONB)

func (*IdentifiableJsonPostgresPersistence[T, K]) UpdatePartially

func (c *IdentifiableJsonPostgresPersistence[T, K]) UpdatePartially(ctx context.Context, correlationId string,
	id K, data cdata.AnyValueMap) (result T, err error)

UpdatePartially updates only few selected fields in a data item.

Parameters:
	- ctx context.Context
	- correlation_id    (optional) transaction id to trace execution through call chain.
	- id                an id of data item to be updated.
	- data              a map with fields to be updated.

Returns: receives updated item or error.

type IdentifiablePostgresPersistence

type IdentifiablePostgresPersistence[T any, K any] struct {
	*PostgresPersistence[T]
}

IdentifiablePostgresPersistence Abstract persistence component that stores data in PostgreSQL and implements a number of CRUD operations over data items with unique ids. The data items must implement IIdentifiable interface.

In basic scenarios child classes shall only override getPageByFilter, getListByFilter or deleteByFilter operations with specific filter function. All other operations can be used out of the box.

In complex scenarios child classes can implement additional operations by accessing c._collection and c._model properties.

Configuration parameters
	- collection:               (optional) PostgreSQL collection name
	- connection(s):
		- discovery_key:        (optional) a key to retrieve the connection from IDiscovery
		- host:                 host name or IP address
		- port:                 port number (default: 27017)
		- uri:                  resource URI or connection string with all parameters in it
	- credential(s):
		- store_key:            (optional) a key to retrieve the credentials from ICredentialStore
		- username:             (optional) user name
		- password:             (optional) user password
	- options:
		- connect_timeout:      (optional) number of milliseconds to wait before timing out when connecting a new client (default: 0)
		- idle_timeout:         (optional) number of milliseconds a client must sit idle in the pool and not be checked out (default: 10000)
		- max_pool_size:        (optional) maximum number of clients the pool should contain (default: 10)

References
	- *:logger:*:*:1.0           (optional) ILogger components to pass log messages components to pass log messages
	- *:discovery:*:*:1.0        (optional) IDiscovery services
	- *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials
*
### Example ###
	type DummyPostgresPersistence struct {
		*persist.IdentifiablePostgresPersistence[fixtures.Dummy, string]
	}

	func NewDummyPostgresPersistence() *DummyPostgresPersistence {
		c := &DummyPostgresPersistence{}
		c.IdentifiablePostgresPersistence = persist.InheritIdentifiablePostgresPersistence[fixtures.Dummy, string](c, "dummies")
		return c
	}

	func (c *DummyPostgresPersistence) DefineSchema() {
		c.ClearSchema()
		c.IdentifiablePostgresPersistence.DefineSchema()
		// Row name must be in double quotes for properly case!!!
		c.EnsureSchema("CREATE TABLE " + c.QuotedTableName() + " (\"id\" TEXT PRIMARY KEY, \"key\" TEXT, \"content\" TEXT)")
		c.EnsureIndex(c.IdentifiablePostgresPersistence.TableName+"_key", map[string]string{"key": "1"}, map[string]string{"unique": "true"})
	}

	func (c *DummyPostgresPersistence) GetPageByFilter(ctx context.Context, correlationId string,
		filter cdata.FilterParams, paging cdata.PagingParams) (page cdata.DataPage[fixtures.Dummy], err error) {

		key, ok := filter.GetAsNullableString("Key")
		filterObj := ""
		if ok && key != "" {
			filterObj += "key='" + key + "'"
		}
		sorting := ""

		return c.IdentifiablePostgresPersistence.GetPageByFilter(ctx, correlationId,
			filterObj, paging,
			sorting, "",
		)
	}

	func (c *DummyPostgresPersistence) GetCountByFilter(ctx context.Context, correlationId string,
		filter cdata.FilterParams) (count int64, err error) {

		key, ok := filter.GetAsNullableString("Key")
		filterObj := ""
		if ok && key != "" {
			filterObj += "key='" + key + "'"
		}
		return c.IdentifiablePostgresPersistence.GetCountByFilter(ctx, correlationId, filterObj)
	}

	func (c *DummyPostgresPersistence) GetOneRandom(ctx context.Context, correlationId string) (item fixtures.Dummy, err error) {
		return c.IdentifiablePostgresPersistence.GetOneRandom(ctx, correlationId, "")
	}

func InheritIdentifiablePostgresPersistence

func InheritIdentifiablePostgresPersistence[T any, K any](overrides IPostgresPersistenceOverrides[T], tableName string) *IdentifiablePostgresPersistence[T, K]

InheritIdentifiablePostgresPersistence creates a new instance of the persistence component.

Parameters:
	- ctx context.Context
	- overrides References to override virtual methods
	- tableName    (optional) a table name.

func (*IdentifiablePostgresPersistence[T, K]) Create

func (c *IdentifiablePostgresPersistence[T, K]) Create(ctx context.Context, correlationId string, item T) (result T, err error)

Create a data item.

Parameters:
	- ctx context.Context
	- correlation_id    (optional) transaction id to trace execution through call chain.
	- item              an item to be created.
Returns: (optional)  created item or error.

func (*IdentifiablePostgresPersistence[T, K]) DeleteById

func (c *IdentifiablePostgresPersistence[T, K]) DeleteById(ctx context.Context, correlationId string, id K) (result T, err error)

DeleteById deletes a data item by its unique id.

Parameters:
	- ctx context.Context
	- correlation_id    (optional) transaction id to trace execution through call chain.
	- id                an id of the item to be deleted
Returns: (optional)  deleted item or error.

func (*IdentifiablePostgresPersistence[T, K]) DeleteByIds

func (c *IdentifiablePostgresPersistence[T, K]) DeleteByIds(ctx context.Context, correlationId string, ids []K) error

DeleteByIds deletes multiple data items by their unique ids.

Parameters:
	- ctx context.Context
	- correlationId     (optional) transaction id to trace execution through call chain.
	- ids                of data items to be deleted.
Returns: (optional)  error or null for success.

func (*IdentifiablePostgresPersistence[T, K]) GetListByIds

func (c *IdentifiablePostgresPersistence[T, K]) GetListByIds(ctx context.Context, correlationId string,
	ids []K) (items []T, err error)

GetListByIds gets a list of data items retrieved by given unique ids.

Parameters:
	- ctx context.Context
	- correlationId     (optional) transaction id to trace execution through call chain.
	- ids of data items to be retrieved
Returns: a data list or error.

func (*IdentifiablePostgresPersistence[T, K]) GetOneById

func (c *IdentifiablePostgresPersistence[T, K]) GetOneById(ctx context.Context, correlationId string, id K) (item T, err error)

GetOneById gets a data item by its unique id.

Parameters:
	- ctx context.Context
	- correlationId     (optional) transaction id to trace execution through call chain.
	- id                an id of data item to be retrieved.

Returns: data item or error.

func (*IdentifiablePostgresPersistence[T, K]) Set

func (c *IdentifiablePostgresPersistence[T, K]) Set(ctx context.Context, correlationId string, item T) (result T, err error)

Set a data item. If the data item exists it updates it, otherwise it creates a new data item.

Parameters:
	- ctx context.Context
	- correlation_id    (optional) transaction id to trace execution through call chain.
	- item              an item to be set.
Returns: (optional)  updated item or error.

func (*IdentifiablePostgresPersistence[T, K]) Update

func (c *IdentifiablePostgresPersistence[T, K]) Update(ctx context.Context, correlationId string, item T) (result T, err error)

Update a data item.

Parameters:
	- ctx context.Context
	- correlation_id    (optional) transaction id to trace execution through call chain.
	- item              an item to be updated.
Returns          (optional)  updated item or error.

func (*IdentifiablePostgresPersistence[T, K]) UpdatePartially

func (c *IdentifiablePostgresPersistence[T, K]) UpdatePartially(ctx context.Context, correlationId string, id K, data cdata.AnyValueMap) (result T, err error)

UpdatePartially updates only few selected fields in a data item.

Parameters:
	- ctx context.Context
	- correlation_id    (optional) transaction id to trace execution through call chain.
	- id                an id of data item to be updated.
	- data              a map with fields to be updated.
Returns: updated item or error.

type PostgresPersistence

type PostgresPersistence[T any] struct {
	Overrides IPostgresPersistenceOverrides[T]
	// Defines general JSON convertors
	JsonConvertor    cconv.IJSONEngine[T]
	JsonMapConvertor cconv.IJSONEngine[map[string]any]

	//The dependency resolver.
	DependencyResolver *cref.DependencyResolver
	//The logger.
	Logger *clog.CompositeLogger
	//The PostgreSQL connection component.
	Connection *conn.PostgresConnection
	//The PostgreSQL connection pool object.
	Client *pgxpool.Pool
	//The PostgreSQL database name.
	DatabaseName string
	//The PostgreSQL database schema name. If not set use "public" by default
	SchemaName string
	//The PostgreSQL table object.
	TableName   string
	MaxPageSize int
	// contains filtered or unexported fields
}

PostgresPersistence Abstract persistence component that stores data in PostgreSQL using plain driver.

This is the most basic persistence component that is only able to store data items of any type. Specific CRUD operations over the data items must be implemented in child classes by accessing c._db or c._collection properties.

Configuration parameters
	- collection:                  (optional) PostgreSQL collection name
	- schema:                  	   (optional) PostgreSQL schema, default "public"
	- connection(s):
		- discovery_key:             (optional) a key to retrieve the connection from IDiscovery
		- host:                      host name or IP address
		- port:                      port number (default: 27017)
		- uri:                       resource URI or connection string with all parameters in it
	- credential(s):
		- store_key:                 (optional) a key to retrieve the credentials from ICredentialStore
		- username:                  (optional) user name
		- password:                  (optional) user password
	- options:
		- connect_timeout:      (optional) number of milliseconds to wait before timing out when connecting a new client (default: 0)
		- idle_timeout:         (optional) number of milliseconds a client must sit idle in the pool and not be checked out (default: 10000)
		- max_pool_size:        (optional) maximum number of clients the pool should contain (default: 10)

References:
	- *:logger:*:*:1.0           (optional) ILogger components to pass log messages
	- *:discovery:*:*:1.0        (optional) IDiscovery services
	- *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials

func InheritPostgresPersistence

func InheritPostgresPersistence[T any](overrides IPostgresPersistenceOverrides[T], tableName string) *PostgresPersistence[T]

InheritPostgresPersistence creates a new instance of the persistence component.

Parameters:
	- ctx context.Context
	- overrides References to override virtual methods
	- tableName    (optional) a table name.

func (*PostgresPersistence[T]) Clear

func (c *PostgresPersistence[T]) Clear(ctx context.Context, correlationId string) error

Clear component state.

Parameters:
	- ctx context.Context
	- correlationId 	(optional) transaction id to trace execution through call chain.
Returns: error or nil no errors occured.

func (*PostgresPersistence[T]) ClearSchema

func (c *PostgresPersistence[T]) ClearSchema()

ClearSchema clears all auto-created objects

func (*PostgresPersistence[T]) Close

func (c *PostgresPersistence[T]) Close(ctx context.Context, correlationId string) (err error)

Close component and frees used resources.

Parameters:
	- ctx context.Context
	- correlationId (optional) transaction id to trace execution through call chain.
Returns: error or nil no errors occurred.

func (*PostgresPersistence[T]) Configure

func (c *PostgresPersistence[T]) Configure(ctx context.Context, config *cconf.ConfigParams)

Configure component by passing configuration parameters.

Parameters:
	- ctx context.Context
	- config configuration parameters to be set.

func (*PostgresPersistence[T]) ConvertFromPublic

func (c *PostgresPersistence[T]) ConvertFromPublic(value T) (map[string]any, error)

ConvertFromPublic сonvert object value from func (c * PostgresPersistence) to internal format.

Parameters:
	- value an object in func (c * PostgresPersistence) format to convert.
Returns: converted object in internal format.

func (*PostgresPersistence[T]) ConvertFromPublicPartial

func (c *PostgresPersistence[T]) ConvertFromPublicPartial(value map[string]any) (map[string]any, error)

ConvertFromPublicPartial converts the given object from the public partial format.

Parameters:
	- value the object to convert from the public partial format.
Returns: the initial object.

func (*PostgresPersistence[T]) ConvertToPublic

func (c *PostgresPersistence[T]) ConvertToPublic(rows pgx.Rows) (T, error)

ConvertToPublic converts object value from internal to func (c * PostgresPersistence) format.

Parameters:
	- value an object in internal format to convert.
Returns: converted object in func (c * PostgresPersistence) format.

func (*PostgresPersistence[T]) Create

func (c *PostgresPersistence[T]) Create(ctx context.Context, correlationId string, item T) (result T, err error)

Create creates a data item.

Parameters:
	- ctx context.Context
	- correlation_id    (optional) transaction id to trace execution through call chain.
	- item              an item to be created.
Returns: (optional) callback function that receives created item or error.

func (*PostgresPersistence[T]) CreateSchema

func (c *PostgresPersistence[T]) CreateSchema(ctx context.Context, correlationId string) (err error)

func (*PostgresPersistence[T]) DefineSchema

func (c *PostgresPersistence[T]) DefineSchema()

DefineSchema a database schema for this persistence, have to call in child class

func (*PostgresPersistence[T]) DeleteByFilter

func (c *PostgresPersistence[T]) DeleteByFilter(ctx context.Context, correlationId string, filter string) error

DeleteByFilter deletes data items that match to a given filter. This method shall be called by a func (c * PostgresPersistence) deleteByFilter method from child class that receives FilterParams and converts them into a filter function.

Parameters:
	- ctx context.Context
	- correlationId     (optional) transaction id to trace execution through call chain.
	- filter            (optional) a filter JSON object.
Returns: error or nil for success.

func (*PostgresPersistence[T]) EnsureIndex

func (c *PostgresPersistence[T]) EnsureIndex(name string, keys map[string]string, options map[string]string)

EnsureIndex adds index definition to create it on opening

Parameters:
	- keys index keys (fields)
	- options index options

func (*PostgresPersistence[T]) EnsureSchema

func (c *PostgresPersistence[T]) EnsureSchema(schemaStatement string)

EnsureSchema adds a statement to schema definition

	Parameters:
  - schemaStatement a statement to be added to the schema

func (*PostgresPersistence[T]) GenerateColumns

func (c *PostgresPersistence[T]) GenerateColumns(columns []string) string

GenerateColumns generates a list of column names to use in SQL statements like: "column1,column2,column3"

Parameters:
	- columns an array with column values
Returns: a generated list of column names

func (*PostgresPersistence[T]) GenerateColumnsAndValues

func (c *PostgresPersistence[T]) GenerateColumnsAndValues(objMap map[string]any) ([]string, []any)

GenerateColumnsAndValues generates a list of column parameters

Parameters:
	- values an array with column values or a key-value map
Returns: a generated list of column values

func (*PostgresPersistence[T]) GenerateParameters

func (c *PostgresPersistence[T]) GenerateParameters(valuesCount int) string

GenerateParameters generates a list of value parameters to use in SQL statements like: "$1,$2,$3"

Parameters:
	- values an array with column values or a key-value map
Returns: a generated list of value parameters

func (*PostgresPersistence[T]) GenerateSetParameters

func (c *PostgresPersistence[T]) GenerateSetParameters(columns []string) string

GenerateSetParameters generates a list of column sets to use in UPDATE statements like: column1=$1,column2=$2

Parameters:
	- values an array with column values or a key-value map
Returns: a generated list of column sets

func (*PostgresPersistence[T]) GetCountByFilter

func (c *PostgresPersistence[T]) GetCountByFilter(ctx context.Context, correlationId string,
	filter string) (int64, error)

GetCountByFilter gets a number of data items retrieved by a given filter. This method shall be called by a func (c * PostgresPersistence) getCountByFilter method from child class that receives FilterParams and converts them into a filter function.

Parameters:
	- ctx context.Context
	- correlationId     (optional) transaction id to trace execution through call chain.
	- filter            (optional) a filter JSON object
Returns: data page or error.

func (*PostgresPersistence[T]) GetListByFilter

func (c *PostgresPersistence[T]) GetListByFilter(ctx context.Context, correlationId string,
	filter string, sort string, selection string) (items []T, err error)

GetListByFilter gets a list of data items retrieved by a given filter and sorted according to sort parameters. This method shall be called by a func (c * PostgresPersistence) getListByFilter method from child class that receives FilterParams and converts them into a filter function.

Parameters:
	- ctx context.Context
	- correlationId    (optional) transaction id to trace execution through call chain.
	- filter           (optional) a filter JSON object
	- paging           (optional) paging parameters
	- sort             (optional) sorting JSON object
	- select           (optional) projection JSON object
Returns: data list or error.

func (*PostgresPersistence[T]) GetOneRandom

func (c *PostgresPersistence[T]) GetOneRandom(ctx context.Context, correlationId string, filter string) (item T, err error)

GetOneRandom gets a random item from items that match to a given filter. This method shall be called by a func (c * PostgresPersistence) getOneRandom method from child class that receives FilterParams and converts them into a filter function.

Parameters:
	- ctx context.Context
	- correlationId     (optional) transaction id to trace execution through call chain.
	- filter            (optional) a filter JSON object
Returns: random item or error.

func (*PostgresPersistence[T]) GetPageByFilter

func (c *PostgresPersistence[T]) GetPageByFilter(ctx context.Context, correlationId string,
	filter string, paging cdata.PagingParams, sort string, selection string) (page cdata.DataPage[T], err error)

GetPageByFilter gets a page of data items retrieved by a given filter and sorted according to sort parameters. This method shall be called by a func (c * PostgresPersistence) getPageByFilter method from child class that receives FilterParams and converts them into a filter function.

Parameters:
	- ctx context.Context
	- correlationId     (optional) transaction id to trace execution through call chain.
	- filter            (optional) a filter JSON object
	- paging            (optional) paging parameters
	- sort              (optional) sorting JSON object
	- select            (optional) projection JSON object
Returns: receives a data page or error.

func (*PostgresPersistence[T]) IsOpen

func (c *PostgresPersistence[T]) IsOpen() bool

IsOpen checks if the component is opened.

Returns: true if the component has been opened and false otherwise.

func (*PostgresPersistence[T]) IsTerminated

func (c *PostgresPersistence[T]) IsTerminated() bool

IsTerminated checks if the wee need to terminate process before close component.

Returns: true if you need terminate your processes.

func (*PostgresPersistence[T]) Open

func (c *PostgresPersistence[T]) Open(ctx context.Context, correlationId string) (err error)

Open the component.

Parameters:
	- ctx context.Context
	- correlationId (optional) transaction id to trace execution through call chain.
Returns: error or nil no errors occurred.

func (*PostgresPersistence[T]) QuoteIdentifier

func (c *PostgresPersistence[T]) QuoteIdentifier(value string) string

func (*PostgresPersistence[T]) QuotedTableName

func (c *PostgresPersistence[T]) QuotedTableName() string

QuotedTableName return quoted SchemaName with TableName ("schema"."table")

func (*PostgresPersistence[T]) SetReferences

func (c *PostgresPersistence[T]) SetReferences(ctx context.Context, references cref.IReferences)

SetReferences to dependent components.

Parameters:
	- ctx context.Context
	- references references to locate the component dependencies.

func (*PostgresPersistence[T]) UnsetReferences

func (c *PostgresPersistence[T]) UnsetReferences()

UnsetReferences (clears) previously set references to dependent components.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL