Documentation
¶
Index ¶
- Variables
- func Decrypt(cipherText []byte, decryptKey string) string
- func DefaultDecrypt(cipherText []byte) string
- func DefaultEncrypt(text string) []byte
- func Encrypt(text string, encryptKey string) []byte
- func NewAndQueryBuilder() *builder.QueryBuilder
- func NewOrQueryBuilder() *builder.QueryBuilder
- type DB
- func DefaultMySQL() (*DB, error)
- func DefaultPostgres() (*DB, error)
- func MySQL(host, port, username, password, databaseName string, silent ...bool) (*DB, error)
- func NewDB(db *gorm.DB) *DB
- func Postgres(host, port, username, password, databaseName string, silent ...bool) (*DB, error)
- func SQLite(path string, silent ...bool) (*DB, error)
- func SqliteMemory() (*DB, error)
- func (db *DB) And(queries ...*query.Query) *query.Query
- func (db *DB) AutoMigrate(models ...any) error
- func (db *DB) Begin() *DB
- func (db *DB) Commit() *DB
- func (db *DB) Eq(field string, value any) *query.Query
- func (db *DB) Gt(field string, value any) *query.Query
- func (db *DB) Gte(field string, value any) *query.Query
- func (db *DB) In(field string, value []any) *query.Query
- func (db *DB) IsNotNull(field string) *query.Query
- func (db *DB) IsNull(field string) *query.Query
- func (db *DB) Joins(associations ...string) *DB
- func (db *DB) Like(field string, value any) *query.Query
- func (db *DB) Lt(field string, value any) *query.Query
- func (db *DB) Lte(field string, value any) *query.Query
- func (db *DB) Neq(field string, value any) *query.Query
- func (db *DB) NotIn(field string, value []any) *query.Query
- func (db *DB) NotLike(field string, value any) *query.Query
- func (db *DB) NotSimilar(field string, value any) *query.Query
- func (db *DB) Omit(fields ...string) *DB
- func (db *DB) Or(queries ...*query.Query) *query.Query
- func (db *DB) Preload(associations ...string) *DB
- func (d *DB) Query(query *query.Query) *DB
- func (db *DB) Rollback() *DB
- func (db *DB) Similar(field string, value any) *query.Query
- func (db *DB) Unscoped() *DB
- type Page
- type Sort
Constants ¶
This section is empty.
Variables ¶
var ( METAORM_HOST = env.New("METAORM_HOST", false) METAORM_PORT = env.New("METAORM_PORT", false) METAORM_USERNAME = env.New("METAORM_USERNAME", false) METAORM_PASSWORD = env.New("METAORM_PASSWORD", false) METAORM_DATABASE = env.New("METAORM_DATABASE", false) METAORM_ENCRYPT_KEY = env.New("METAORM_ENCRYPT_KEY", false) )
Functions ¶
func DefaultDecrypt ¶ added in v1.1.0
DefaultDecrypt decrypts the given cipher text using the METAORM_ENCRYPT_KEY environment variable.
func DefaultEncrypt ¶ added in v1.1.0
DefaultEncrypt encrypts the given text using the METAORM_ENCRYPT_KEY environment variable.
func NewAndQueryBuilder ¶
func NewAndQueryBuilder() *builder.QueryBuilder
NewAndQueryBuilder returns a new and query builder. The default operator is and.
func NewOrQueryBuilder ¶
func NewOrQueryBuilder() *builder.QueryBuilder
NewOrQueryBuilder returns a new or query builder. The default operator is or.
Types ¶
type DB ¶ added in v1.1.0
func DefaultMySQL ¶
DefaultMySQL returns a new database connection for MySQL using the environment variables.
func DefaultPostgres ¶
DefaultPostgres returns a new database connection for Postgres using the environment variables.
func SqliteMemory ¶
SqliteMemory returns a new database connection for SQLite in-memory.
func (*DB) And ¶ added in v1.1.0
And returns a new query with the and operator for the given queries.
func (*DB) AutoMigrate ¶ added in v1.1.0
AutoMigrate runs the auto migration for the given models. It returns an error if the migration fails.
func (*DB) Eq ¶ added in v1.1.0
Eq returns a new query with the equal operator for the given field and value. If the field is prefixed with a *, it will be decrypted.
func (*DB) Gt ¶ added in v1.1.0
Gt returns a new query with the greater than operator for the given field and value.
func (*DB) Gte ¶ added in v1.1.0
Gte returns a new query with the greater than or equal operator for the given field and value.
func (*DB) In ¶ added in v1.1.0
In returns a new query with the in operator for the given field and value. If the field is prefixed with a *, it will be decrypted.
func (*DB) IsNotNull ¶ added in v1.1.0
IsNotNull returns a new query with the is not null operator for the given field.
func (*DB) IsNull ¶ added in v1.1.0
IsNull returns a new query with the is null operator for the given field.
func (*DB) Like ¶ added in v1.1.0
Like returns a new query with the like operator for the given field and value. If the field is prefixed with a *, it will be decrypted.
func (*DB) Lt ¶ added in v1.1.0
Lt returns a new query with the less than operator for the given field and value.
func (*DB) Lte ¶ added in v1.1.0
Lte returns a new query with the less than or equal operator for the given field and value.
func (*DB) Neq ¶ added in v1.1.0
Neq returns a new query with the not equal operator for the given field and value. If the field is prefixed with a *, it will be decrypted.
func (*DB) NotIn ¶ added in v1.1.0
NotIn returns a new query with the not in operator for the given field and value. If the field is prefixed with a *, it will be decrypted.
func (*DB) NotLike ¶ added in v1.1.0
NotLike returns a new query with the not like operator for the given field and value. If the field is prefixed with a *, it will be decrypted.
func (*DB) NotSimilar ¶ added in v1.1.0
NotSimilar returns a new query with the not similar operator for the given field and value. If the field is prefixed with a *, it will be decrypted.
func (*DB) Query ¶ added in v1.1.0
Query consumes the query and returns a new DB instance with the where clause applied.
type Page ¶
type Page struct {
Page int `json:"page" form:"page"`
Size int `json:"size" form:"size"`
Total int `json:"total" form:"-"`
}
Page is a pagination model.