Documentation ¶
Index ¶
- Constants
- func BoolToInt16(val bool) int16
- func GetDbUrl(cfg *ConnectConfig) string
- func HandlePgxRollback(ctx context.Context, tx PgxRollbackInterface, logger *slog.Logger)
- func HandleSqlRollback(tx SqlRollbackInterface, logger *slog.Logger)
- func Int16ToBool(val int16) bool
- func IsConflict(err error) bool
- func IsNoRows(err error) bool
- func ToNullableString(text pgtype.Text) *string
- func ToTimestamp(value time.Time) (pgtype.Timestamp, error)
- func ToUuid(value string) (pgtype.UUID, error)
- func UUIDString(value pgtype.UUID) string
- func UUIDStrings(values []pgtype.UUID) []string
- type BaseDBTX
- type ConnectConfig
- type CreateAccountApiKeyRequest
- type CreateJobConnectionDestination
- type DBTX
- type MockDBTX
- func (_m *MockDBTX) Begin(ctx context.Context) (pgx.Tx, error)
- func (_m *MockDBTX) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
- func (_m *MockDBTX) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (_m *MockDBTX) EXPECT() *MockDBTX_Expecter
- func (_m *MockDBTX) Exec(_a0 context.Context, _a1 string, _a2 ...interface{}) (pgconn.CommandTag, error)
- func (_m *MockDBTX) Ping(ctx context.Context) error
- func (_m *MockDBTX) Query(_a0 context.Context, _a1 string, _a2 ...interface{}) (pgx.Rows, error)
- func (_m *MockDBTX) QueryRow(_a0 context.Context, _a1 string, _a2 ...interface{}) pgx.Row
- type MockDBTX_BeginTx_Call
- func (_c *MockDBTX_BeginTx_Call) Return(_a0 pgx.Tx, _a1 error) *MockDBTX_BeginTx_Call
- func (_c *MockDBTX_BeginTx_Call) Run(run func(ctx context.Context, txOptions pgx.TxOptions)) *MockDBTX_BeginTx_Call
- func (_c *MockDBTX_BeginTx_Call) RunAndReturn(run func(context.Context, pgx.TxOptions) (pgx.Tx, error)) *MockDBTX_BeginTx_Call
- type MockDBTX_Begin_Call
- type MockDBTX_CopyFrom_Call
- type MockDBTX_Exec_Call
- func (_c *MockDBTX_Exec_Call) Return(_a0 pgconn.CommandTag, _a1 error) *MockDBTX_Exec_Call
- func (_c *MockDBTX_Exec_Call) Run(run func(_a0 context.Context, _a1 string, _a2 ...interface{})) *MockDBTX_Exec_Call
- func (_c *MockDBTX_Exec_Call) RunAndReturn(run func(context.Context, string, ...interface{}) (pgconn.CommandTag, error)) *MockDBTX_Exec_Call
- type MockDBTX_Expecter
- func (_e *MockDBTX_Expecter) Begin(ctx interface{}) *MockDBTX_Begin_Call
- func (_e *MockDBTX_Expecter) BeginTx(ctx interface{}, txOptions interface{}) *MockDBTX_BeginTx_Call
- func (_e *MockDBTX_Expecter) CopyFrom(ctx interface{}, tableName interface{}, columnNames interface{}, ...) *MockDBTX_CopyFrom_Call
- func (_e *MockDBTX_Expecter) Exec(_a0 interface{}, _a1 interface{}, _a2 ...interface{}) *MockDBTX_Exec_Call
- func (_e *MockDBTX_Expecter) Ping(ctx interface{}) *MockDBTX_Ping_Call
- func (_e *MockDBTX_Expecter) Query(_a0 interface{}, _a1 interface{}, _a2 ...interface{}) *MockDBTX_Query_Call
- func (_e *MockDBTX_Expecter) QueryRow(_a0 interface{}, _a1 interface{}, _a2 ...interface{}) *MockDBTX_QueryRow_Call
- type MockDBTX_Ping_Call
- type MockDBTX_QueryRow_Call
- func (_c *MockDBTX_QueryRow_Call) Return(_a0 pgx.Row) *MockDBTX_QueryRow_Call
- func (_c *MockDBTX_QueryRow_Call) Run(run func(_a0 context.Context, _a1 string, _a2 ...interface{})) *MockDBTX_QueryRow_Call
- func (_c *MockDBTX_QueryRow_Call) RunAndReturn(run func(context.Context, string, ...interface{}) pgx.Row) *MockDBTX_QueryRow_Call
- type MockDBTX_Query_Call
- func (_c *MockDBTX_Query_Call) Return(_a0 pgx.Rows, _a1 error) *MockDBTX_Query_Call
- func (_c *MockDBTX_Query_Call) Run(run func(_a0 context.Context, _a1 string, _a2 ...interface{})) *MockDBTX_Query_Call
- func (_c *MockDBTX_Query_Call) RunAndReturn(run func(context.Context, string, ...interface{}) (pgx.Rows, error)) *MockDBTX_Query_Call
- type MockTx
- func (m *MockTx) Begin(ctx context.Context) (pgx.Tx, error)
- func (m *MockTx) Commit(ctx context.Context) error
- func (m *MockTx) Conn() *pgx.Conn
- func (m *MockTx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, ...) (int64, error)
- func (m *MockTx) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
- func (m *MockTx) LargeObjects() pgx.LargeObjects
- func (m *MockTx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
- func (m *MockTx) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
- func (m *MockTx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
- func (m *MockTx) Rollback(ctx context.Context) error
- func (m *MockTx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
- type NucleusDb
- func (d *NucleusDb) CreateAccountApikey(ctx context.Context, req *CreateAccountApiKeyRequest) (*db_queries.NeosyncApiAccountApiKey, error)
- func (d *NucleusDb) CreateJob(ctx context.Context, cjParams *db_queries.CreateJobParams, ...) (*db_queries.NeosyncApiJob, error)
- func (d *NucleusDb) CreateTeamAccount(ctx context.Context, userId pgtype.UUID, teamName string) (*db_queries.NeosyncApiAccount, error)
- func (d *NucleusDb) CreateTeamAccountInvite(ctx context.Context, accountId pgtype.UUID, userId pgtype.UUID, email string, ...) (*db_queries.NeosyncApiAccountInvite, error)
- func (d *NucleusDb) SetPersonalAccount(ctx context.Context, userId pgtype.UUID) (*db_queries.NeosyncApiAccount, error)
- func (d *NucleusDb) SetSourceSubsets(ctx context.Context, jobId pgtype.UUID, ...) error
- func (d *NucleusDb) SetUserByAuthSub(ctx context.Context, authSub string) (*db_queries.NeosyncApiUser, error)
- func (d *NucleusDb) ValidateInviteAddUserToAccount(ctx context.Context, userId pgtype.UUID, token string, userEmail string) (pgtype.UUID, error)
- func (d *NucleusDb) WithTx(ctx context.Context, opts *pgx.TxOptions, fn func(db BaseDBTX) error) error
- type PgxRollbackInterface
- type SqlRollbackInterface
Constants ¶
const (
PqUniqueViolationCode = "23505"
)
Variables ¶
This section is empty.
Functions ¶
func BoolToInt16 ¶
func GetDbUrl ¶
func GetDbUrl(cfg *ConnectConfig) string
func HandlePgxRollback ¶
func HandlePgxRollback(ctx context.Context, tx PgxRollbackInterface, logger *slog.Logger)
Only logs if error is not ErrTxClosed
func HandleSqlRollback ¶
func HandleSqlRollback( tx SqlRollbackInterface, logger *slog.Logger, )
func Int16ToBool ¶
func IsConflict ¶
func ToNullableString ¶
func UUIDString ¶
func UUIDStrings ¶
Types ¶
type BaseDBTX ¶
type BaseDBTX interface { Exec(context.Context, string, ...any) (pgconn.CommandTag, error) Query(context.Context, string, ...any) (pgx.Rows, error) QueryRow(context.Context, string, ...any) pgx.Row CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) }
type ConnectConfig ¶
type CreateJobConnectionDestination ¶
type CreateJobConnectionDestination struct { ConnectionId pgtype.UUID Options *pg_models.JobDestinationOptions }
type MockDBTX ¶
MockDBTX is an autogenerated mock type for the DBTX type
func NewMockDBTX ¶
NewMockDBTX creates a new instance of MockDBTX. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockDBTX) CopyFrom ¶
func (_m *MockDBTX) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
CopyFrom provides a mock function with given fields: ctx, tableName, columnNames, rowSrc
func (*MockDBTX) EXPECT ¶
func (_m *MockDBTX) EXPECT() *MockDBTX_Expecter
func (*MockDBTX) Exec ¶
func (_m *MockDBTX) Exec(_a0 context.Context, _a1 string, _a2 ...interface{}) (pgconn.CommandTag, error)
Exec provides a mock function with given fields: _a0, _a1, _a2
type MockDBTX_BeginTx_Call ¶
MockDBTX_BeginTx_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BeginTx'
func (*MockDBTX_BeginTx_Call) Return ¶
func (_c *MockDBTX_BeginTx_Call) Return(_a0 pgx.Tx, _a1 error) *MockDBTX_BeginTx_Call
func (*MockDBTX_BeginTx_Call) Run ¶
func (_c *MockDBTX_BeginTx_Call) Run(run func(ctx context.Context, txOptions pgx.TxOptions)) *MockDBTX_BeginTx_Call
func (*MockDBTX_BeginTx_Call) RunAndReturn ¶
func (_c *MockDBTX_BeginTx_Call) RunAndReturn(run func(context.Context, pgx.TxOptions) (pgx.Tx, error)) *MockDBTX_BeginTx_Call
type MockDBTX_Begin_Call ¶
MockDBTX_Begin_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Begin'
func (*MockDBTX_Begin_Call) Return ¶
func (_c *MockDBTX_Begin_Call) Return(_a0 pgx.Tx, _a1 error) *MockDBTX_Begin_Call
func (*MockDBTX_Begin_Call) Run ¶
func (_c *MockDBTX_Begin_Call) Run(run func(ctx context.Context)) *MockDBTX_Begin_Call
func (*MockDBTX_Begin_Call) RunAndReturn ¶
func (_c *MockDBTX_Begin_Call) RunAndReturn(run func(context.Context) (pgx.Tx, error)) *MockDBTX_Begin_Call
type MockDBTX_CopyFrom_Call ¶
MockDBTX_CopyFrom_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CopyFrom'
func (*MockDBTX_CopyFrom_Call) Return ¶
func (_c *MockDBTX_CopyFrom_Call) Return(_a0 int64, _a1 error) *MockDBTX_CopyFrom_Call
func (*MockDBTX_CopyFrom_Call) Run ¶
func (_c *MockDBTX_CopyFrom_Call) Run(run func(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource)) *MockDBTX_CopyFrom_Call
func (*MockDBTX_CopyFrom_Call) RunAndReturn ¶
func (_c *MockDBTX_CopyFrom_Call) RunAndReturn(run func(context.Context, pgx.Identifier, []string, pgx.CopyFromSource) (int64, error)) *MockDBTX_CopyFrom_Call
type MockDBTX_Exec_Call ¶
MockDBTX_Exec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exec'
func (*MockDBTX_Exec_Call) Return ¶
func (_c *MockDBTX_Exec_Call) Return(_a0 pgconn.CommandTag, _a1 error) *MockDBTX_Exec_Call
func (*MockDBTX_Exec_Call) Run ¶
func (_c *MockDBTX_Exec_Call) Run(run func(_a0 context.Context, _a1 string, _a2 ...interface{})) *MockDBTX_Exec_Call
func (*MockDBTX_Exec_Call) RunAndReturn ¶
func (_c *MockDBTX_Exec_Call) RunAndReturn(run func(context.Context, string, ...interface{}) (pgconn.CommandTag, error)) *MockDBTX_Exec_Call
type MockDBTX_Expecter ¶
type MockDBTX_Expecter struct {
// contains filtered or unexported fields
}
func (*MockDBTX_Expecter) Begin ¶
func (_e *MockDBTX_Expecter) Begin(ctx interface{}) *MockDBTX_Begin_Call
Begin is a helper method to define mock.On call
- ctx context.Context
func (*MockDBTX_Expecter) BeginTx ¶
func (_e *MockDBTX_Expecter) BeginTx(ctx interface{}, txOptions interface{}) *MockDBTX_BeginTx_Call
BeginTx is a helper method to define mock.On call
- ctx context.Context
- txOptions pgx.TxOptions
func (*MockDBTX_Expecter) CopyFrom ¶
func (_e *MockDBTX_Expecter) CopyFrom(ctx interface{}, tableName interface{}, columnNames interface{}, rowSrc interface{}) *MockDBTX_CopyFrom_Call
CopyFrom is a helper method to define mock.On call
- ctx context.Context
- tableName pgx.Identifier
- columnNames []string
- rowSrc pgx.CopyFromSource
func (*MockDBTX_Expecter) Exec ¶
func (_e *MockDBTX_Expecter) Exec(_a0 interface{}, _a1 interface{}, _a2 ...interface{}) *MockDBTX_Exec_Call
Exec is a helper method to define mock.On call
- _a0 context.Context
- _a1 string
- _a2 ...interface{}
func (*MockDBTX_Expecter) Ping ¶
func (_e *MockDBTX_Expecter) Ping(ctx interface{}) *MockDBTX_Ping_Call
Ping is a helper method to define mock.On call
- ctx context.Context
func (*MockDBTX_Expecter) Query ¶
func (_e *MockDBTX_Expecter) Query(_a0 interface{}, _a1 interface{}, _a2 ...interface{}) *MockDBTX_Query_Call
Query is a helper method to define mock.On call
- _a0 context.Context
- _a1 string
- _a2 ...interface{}
func (*MockDBTX_Expecter) QueryRow ¶
func (_e *MockDBTX_Expecter) QueryRow(_a0 interface{}, _a1 interface{}, _a2 ...interface{}) *MockDBTX_QueryRow_Call
QueryRow is a helper method to define mock.On call
- _a0 context.Context
- _a1 string
- _a2 ...interface{}
type MockDBTX_Ping_Call ¶
MockDBTX_Ping_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Ping'
func (*MockDBTX_Ping_Call) Return ¶
func (_c *MockDBTX_Ping_Call) Return(_a0 error) *MockDBTX_Ping_Call
func (*MockDBTX_Ping_Call) Run ¶
func (_c *MockDBTX_Ping_Call) Run(run func(ctx context.Context)) *MockDBTX_Ping_Call
func (*MockDBTX_Ping_Call) RunAndReturn ¶
func (_c *MockDBTX_Ping_Call) RunAndReturn(run func(context.Context) error) *MockDBTX_Ping_Call
type MockDBTX_QueryRow_Call ¶
MockDBTX_QueryRow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryRow'
func (*MockDBTX_QueryRow_Call) Return ¶
func (_c *MockDBTX_QueryRow_Call) Return(_a0 pgx.Row) *MockDBTX_QueryRow_Call
func (*MockDBTX_QueryRow_Call) Run ¶
func (_c *MockDBTX_QueryRow_Call) Run(run func(_a0 context.Context, _a1 string, _a2 ...interface{})) *MockDBTX_QueryRow_Call
func (*MockDBTX_QueryRow_Call) RunAndReturn ¶
func (_c *MockDBTX_QueryRow_Call) RunAndReturn(run func(context.Context, string, ...interface{}) pgx.Row) *MockDBTX_QueryRow_Call
type MockDBTX_Query_Call ¶
MockDBTX_Query_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Query'
func (*MockDBTX_Query_Call) Return ¶
func (_c *MockDBTX_Query_Call) Return(_a0 pgx.Rows, _a1 error) *MockDBTX_Query_Call
func (*MockDBTX_Query_Call) Run ¶
func (_c *MockDBTX_Query_Call) Run(run func(_a0 context.Context, _a1 string, _a2 ...interface{})) *MockDBTX_Query_Call
func (*MockDBTX_Query_Call) RunAndReturn ¶
func (_c *MockDBTX_Query_Call) RunAndReturn(run func(context.Context, string, ...interface{}) (pgx.Rows, error)) *MockDBTX_Query_Call
type MockTx ¶
MockTx is a mock type for the Tx interface
func (*MockTx) LargeObjects ¶
func (m *MockTx) LargeObjects() pgx.LargeObjects
type NucleusDb ¶
type NucleusDb struct { Db DBTX Q db_queries.Querier }
func NewFromConfig ¶
func NewFromConfig(config *ConnectConfig) (*NucleusDb, error)
func (*NucleusDb) CreateAccountApikey ¶
func (d *NucleusDb) CreateAccountApikey( ctx context.Context, req *CreateAccountApiKeyRequest, ) (*db_queries.NeosyncApiAccountApiKey, error)
func (*NucleusDb) CreateJob ¶
func (d *NucleusDb) CreateJob( ctx context.Context, cjParams *db_queries.CreateJobParams, destinations []*CreateJobConnectionDestination, ) (*db_queries.NeosyncApiJob, error)
func (*NucleusDb) CreateTeamAccount ¶
func (d *NucleusDb) CreateTeamAccount( ctx context.Context, userId pgtype.UUID, teamName string, ) (*db_queries.NeosyncApiAccount, error)
func (*NucleusDb) CreateTeamAccountInvite ¶
func (*NucleusDb) SetPersonalAccount ¶
func (d *NucleusDb) SetPersonalAccount( ctx context.Context, userId pgtype.UUID, ) (*db_queries.NeosyncApiAccount, error)
func (*NucleusDb) SetSourceSubsets ¶ added in v0.4.50
func (*NucleusDb) SetUserByAuthSub ¶
func (d *NucleusDb) SetUserByAuthSub( ctx context.Context, authSub string, ) (*db_queries.NeosyncApiUser, error)
func (*NucleusDb) ValidateInviteAddUserToAccount ¶
type PgxRollbackInterface ¶
type SqlRollbackInterface ¶
type SqlRollbackInterface interface {
Rollback() error
}