Documentation ¶
Index ¶
- func OverrideConfigSettings(config *pgx.ConnConfig, jsonContent map[string]interface{})
- type DB
- func (m *DB) Analyze(options Options)
- func (m *DB) Associate(ctx context.Context, table string, column string, pk interface{}, _ string, ...)
- func (m *DB) Delete(ctx context.Context, table string, pkName string, pkValue interface{})
- func (m *DB) FormatArgument(n int) string
- func (m *DB) Insert(ctx context.Context, table string, fields map[string]interface{}) string
- func (m *DB) Model() *db.Model
- func (m *DB) NewBuilder(ctx context.Context) QueryBuilderI
- func (m *DB) OperationSql(op Operator, operandStrings []string) (sql string)
- func (m *DB) QuoteIdentifier(v string) string
- func (m *DB) Update(ctx context.Context, table string, fields map[string]any, pkName string, ...)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OverrideConfigSettings ¶
func OverrideConfigSettings(config *pgx.ConnConfig, jsonContent map[string]interface{})
OverrideConfigSettings will use a map read in from a json file to modify the given config settings
Types ¶
type DB ¶
DB is the goradd driver for postgresql databases.
func NewDB ¶
NewDB returns a new Postgresql DB database object based on the pgx driver that you can add to the datastore. If connectionString is set, it will be used to create the configuration. Otherwise, use a config setting. Using a configSetting can potentially give you access to the underlying pgx database for advanced operations.
The postgres driver specifies that you must use ParseConfig to create the initial configuration, although that can be sent a blank string to gather initial values from environment variables. You can then change items in the configuration structure. For example:
config,_ := pgx.ParseConfig(connectionString) config.Password = "mysecret" db := pgsql.NewDB(key, "", config)
func (*DB) Associate ¶
func (m *DB) Associate(ctx context.Context, table string, column string, pk interface{}, _ string, relatedColumn string, relatedPks interface{})
Associate sets up the many-many association pointing from the given table and column to another table and column. table is the name of the association table. column is the name of the column in the association table that contains the pk for the record we are associating. pk is the value of the primary key. relatedTable is the table the association is pointing to. relatedColumn is the column in the association table that points to the relatedTable's pk. relatedPks are the new primary keys in the relatedTable we are associating.
func (*DB) FormatArgument ¶
FormatArgument formats the given argument number for embedding in a SQL statement.
func (*DB) Insert ¶
Insert inserts the given data as a new record in the database. It returns the record id of the new record.
func (*DB) NewBuilder ¶
NewBuilder returns a new query builder to build a query that will be processed by the database.
func (*DB) OperationSql ¶
OperationSql provides Postgres specific SQL for certain operators.
func (*DB) QuoteIdentifier ¶
QuoteIdentifier surrounds the given identifier with quote characters appropriate for Postgres
type Options ¶
type Options struct { // EnumTableSuffix is the suffix in the name of a table that tells GoRADD to treat // the table as a enum table. Defaults to "_enum" if not set. EnumTableSuffix string // AssociationTableSuffix is the suffix in the name of a table that tells GoRADD to // treat the table as an association table. Defaults to "_assn". AssociationTableSuffix string // ForeignKeySuffix is the suffix to strip off the ends of names of foreign keys when converting // them to internal names. For example, if the suffix is "_id", and a column named // manager_id a "project" table is a foreign key to a "person" table, then GoRADD will // create "Person" objects with the name "Manager" inside the "Project" object. // A suffix is required since it will also create a "ManagerID" member variable, and // without the suffix the two values will have the same name. // The default is "_id". ForeignKeySuffix string // UseQualifiedNames will force goradd to prepend schema names in front of table names. // This is required to clear up ambiguity when different schemas have the same table name. // Postgres documentation discourages the use of repeated table names in different schemas. // If you know you do not have repeats, you can leave this option false. UseQualifiedNames bool // Schemas lets you specify which specific schemas you want to select. // If no schemas are specified, then all available schemas will be used. Schemas []string }
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns default database analysis options for MySQL databases.