Documentation ¶
Index ¶
- type ORM
- func (orm *ORM) Close() error
- func (orm *ORM) Create(ctx context.Context, v any) error
- func (orm *ORM) DB() *sql.DB
- func (orm *ORM) Delete(ctx context.Context, v any) error
- func (orm *ORM) Exec(ctx context.Context, q *dml.Query, v any) error
- func (orm *ORM) Find(ctx context.Context, v any) error
- func (orm *ORM) NewQuery() *dml.Query
- func (orm *ORM) Query(ctx context.Context, q *dml.Query, v any) error
- func (orm *ORM) Update(ctx context.Context, v any, columns ...string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ORM ¶
type ORM struct {
// contains filtered or unexported fields
}
ORM is a handle representing an object relational mapper. The ORM wraps an underlying SQL database connection and maps database rows to structs.
func Open ¶
Open opens a new database connection with the given configuration and returns a new ORM.
func (*ORM) Delete ¶
Delete deletes the database row corresponding to the value v. The value should be a pointer to a struct.
func (*ORM) Exec ¶
Exec executes a query without returning any results. If the final argument v is not nil, v must be a pointer to a struct. If v is specified the last inserted ID will be set after executing the query.
func (*ORM) Find ¶
Find finds the database row corresponding to the value v. The value should be a pointer to a struct with any primary key fields populated. The struct will be filled if a row is found.
func (*ORM) NewQuery ¶
NewQuery creates a new dml.Query pre-configured for the ORM's database dialect.
func (*ORM) Query ¶
Query executes the query q and scans the results into v. The value v must be a pointer to a struct, slice, or array. If a struct is provided but the query returns more than 1 row, only the first row will be scanned. If a slice is provided rows will be appended.
func (*ORM) Update ¶
Update updates the database row corresponding to the value v. The value should be a pointer to a struct. The struct's primary key values are used to constrain the update statement. The remaining arguments may be used to specify a subset of columns that should be updated. If no column names are specified, all columns are updated.