Categorygithub.com/go-rel/rel
modulepackage
0.42.0
Repository: https://github.com/go-rel/rel.git
Documentation: pkg.go.dev

# README

REL

GoDoc Build Status Go Report Card Maintainability Codecov Gitter chat

Modern Database Access Layer for Golang.

REL is golang orm-ish database layer for layered architecture. It's testable and comes with its own test library. REL also features extendable query builder that allows you to write query using builder or plain sql.

Features

  • Testable repository with builtin reltest package.
  • Seamless nested transactions.
  • Elegant, yet extendable query builder with mix of syntactic sugar.
  • Supports Eager loading.
  • Composite Primary Key.
  • Multi adapter.
  • Soft Deletion.
  • Pagination.
  • Schema Migration.

Install

go get github.com/go-rel/rel

Getting Started

Examples

License

Released under the MIT License

# Packages

Package group is syntatic sugar for building group query.
Package join is syntatic sugar for building join query.
No description provided by the author
Package sort is syntatic sugar for building sort query.
Package where is syntatic sugar for building where query.

# Functions

All warp a query into ALL(sub-query) Some database may not support this keyword, please consult to your database documentation.
And compares other filters using and.
Any warp a query into ANY(sub-query) Some database may not support this keyword, please consult to your database documentation.
Apply using given mutators.
BatchSize specifies the size of iterator batch.
Build for given table using given queriers.
Dec create a mutate using deccrement operation.
DecBy create a mutate using decrement operation with custom decrement value.
Default allows to set a default value on the column.).
DefaultLogger instrumentation to log queries and rel operation.
Eq expression field equal to value.
FilterFragment add custom filter.
Finish specifies the primary value to finish at (inclusive).
ForUpdate lock query.
From create a query with chainable syntax, using from as the starting point.
Gt compares that left value is greater than to right value.
Gte compares that left value is greater than or equal to right value.
In check whethers value of the field is included in values.
Inc create a mutate using increment operation.
IncBy create a mutate using increment operation with custom increment value.
InInt check whethers integer values of the field is included.
InString check whethers string values of the field is included.
InUint check whethers unsigned integer values of the field is included.
Join create a query with chainable syntax, using join as the starting point.
JoinAssoc create a query with chainable syntax, using join as the starting point.
JoinAssocWith create a query with chainable syntax, using join as the starting point.
Joinf create a query with chainable syntax, using join as the starting point.
JoinOn create a query with chainable syntax, using join as the starting point.
JoinWith create a query with chainable syntax, using join as the starting point.
Like compares value of field to match string pattern.
Lt compares that left value is less than to right value.
Lte compares that left value is less than or equal to right value.
Ne compares that left value is not equal to right value.
New create new repo using adapter.
NewChangeset returns new changeset mutator for given entity.
NewCollection used to create abstraction to work with slice.
NewDocument used to create abstraction to work with struct.
No description provided by the author
NewFullJoin with given table and optional filter.
NewFullJoinOn table with given field and optional additional filter.
NewGroup query.
NewInnerJoin with given table and optional filter.
NewInnerJoinOn table with given field and optional additional filter.
NewJoin with given table.
NewJoinAssoc with given association field and optional additional filters.
NewJoinAssocWith with given association field and optional additional filters.
NewJoinFragment defines a join clause using raw query.
NewJoinOn table with given field and optional additional filter.
NewJoinWith query with custom join mode, table, field and additional filters with AND condition.
NewLeftJoin with given table and optional filter.
NewLeftJoinOn table with given field and optional additional filter.
NewRightJoin with given table and optional filter.
NewRightJoinOn table with given field and optional additional filter.
NewSelect query.
NewStructset from a struct.
Nil check whether field is nil.
Nin check whethers value of the field is not included in values.
NinInt check whethers integer values of the is not included.
NinString check whethers string values of the is not included.
NinUint check whethers unsigned integer values of the is not included.
Not wraps filters using not.
NotLike compares value of field to not match string pattern.
NotNil check whether field is not nil.
Nullable wrap value as a nullable sql.Scanner.
OnConflictFragment allows to write custom sql for on conflict.
OnConflictIgnore insertion when conflict happens.
OnConflictKeyIgnore insertion when conflict happens on specific keys.
OnConflictKeyReplace insertion when conflict happens on specific keys.
OnConflictKeysIgnore insertion when conflict happens on specific keys.
OnConflictKeysReplace insertion when conflict happens on specific keys.
OnConflictReplace insertion when conflict happens.
Or compares other filters using or.
Select query create a query with chainable syntax, using select as the starting point.
Set create a mutate using set operation.
SetFragment create a mutate operation using fragment operation.
SortAsc sorts field with ascending sort.
NewSortDesc sorts field with descending sort.
SQL Query.
Start specifies the primary value to start from (inclusive).
No description provided by the author
Where create a query with chainable syntax, using where as the starting point.

# Constants

BelongsTo association.
BigID ColumnType.
BigInt ColumnType.
Bool ColumnType.
ChangeFragmentOp operation.
ChangeIncOp operation.
ChangeInvalidOp operation.
ChangeSetOp operation.
CheckConstraint error type.
Date ColumnType.
DateTime ColumnType.
Decimal ColumnType.
FilterAndOp is filter type for and operator.
FilterEqOp is filter type for equal comparison.
FilterFragmentOp is filter type for custom filter.
FilterGteOp is filter type for greter than or equal comparison.
FilterGtOp is filter type for greater than comparison.
FilterInOp is filter type for inclusion comparison.
FilterLikeOp is filter type for like comparison.
FilterLteOp is filter type for less than or equal comparison.
FilterLtOp is filter type for less than comparison.
FilterNeOp is filter type for not equal comparison.
FilterNilOp is filter type for nil check.
FilterNinOp is filter type for not inclusion comparison.
FilterNotLikeOp is filter type for not like comparison.
FilterNotNilOp is filter type for not nil check.
FilterNotOp is filter type for not operator.
FilterOrOp is filter type for or operator.
Float ColumnType.
ForeignKey KeyType.
ForeignKeyConstraint error type.1.
HasCreatedAt flag.
HasDeleted flag.
HasDeletedAt flag.
HasMany association.
HasOne association.
HasUpdatedAt flag.
Versioning.
ID ColumnType.
Int ColumnType.
Invalid flag.
JSON ColumnType that will fallback to Text ColumnType if adapter does not support it.
NotNullConstraint error type.1.
PrimaryKey KeyType.
PrimaryKeyConstraint error type.1.
SchemaAlter operation.
SchemaCreate operation.
SchemaDrop operation.
SchemaRename operation.
SmallInt ColumnType.
String ColumnType.
Text ColumnType.
Time ColumnType.
UniqueConstraint error type.1.
UniqueKey KeyType.

# Variables

ErrCheckConstraint is an auxiliary variable for error handling.
ErrForeignKeyConstraint is an auxiliary variable for error handling.
ErrNotFound returned when entities not found.
ErrNotNullConstraint is an auxiliary variable for error handling.
ErrPrimaryKeyConstraint is an auxiliary variable for error handling.
ErrUniqueConstraint is an auxiliary variable for error handling.
NewSortAsc sorts field with ascending sort.
NewSortDesc sorts field with descending sort.
No description provided by the author
Setf is an alias for SetFragment.

# Structs

AlterTable Migrator.
Association provides abstraction to work with association of document or collection.
No description provided by the author
AssocMutation represents mutation for association.
Changeset mutator for structs.
Collection provides an abstraction over reflect to easily works with slice for database purpose.
Column definition.
ConstraintError returned whenever constraint error encountered.
Document provides an abstraction over reflect to easily works with struct for database purpose.
No description provided by the author
FilterQuery defines details of a condition type.
ForeignKeyReference definition.
GroupQuery defines group clause of the query.
Index definition.
JoinQuery defines join clause in query.
Key definition.
Mutate stores mutation instruction.
Mutation represents value to be inserted or updated to database.
NotFoundError returned whenever Find returns no result.
OnConflict mutation.
Query defines information about query generated by query builder.
Schema builder.
SelectQuery defines select clause of the query.
SortQuery defines sort information of query.
SQLQuery allows querying using native query supported by database.
Structset can be used as mutation for repository insert or update operation.
SubQuery warps a query into: Prefix (Query).
Table definition.

# Interfaces

Adapter interface.
ColumnOption interface.
Cursor is interface to work with database result (used by adapter).
EntityIterator allows iterating through all entity in database in batch.
No description provided by the author
IndexOption interface.
Iterator allows iterating through all entity in database in batch.
IteratorOption is used to configure iteration behaviour, such as batch size, start id and finish id.
KeyOption interface.
Migration definition.
Mutator is interface for a entity mutator.
Querier interface defines contract to be used for query builder.
No description provided by the author
Repository for interacting with database.
TableDefinition interface.
TableOption interface.

# Type aliases

AssociationType defines the type of association in database.
Cascade enable or disable updating associations.
ChangeOp represents type of mutate operation.
ColumnType definition.
ConstraintType defines the type of constraint error.
Do used internally for schema migration.
DocumentFlag stores information about document as a flag.
ErrorFunc allows conversion REL's error to Application custom errors.
FilterOp defines enumeration of all supported filter types.
Instrumenter defines function type that can be used for instrumetation.
KeyType definition.
Limit options.
Lock query.
Map can be used as mutation for repository insert or update operation.
Name option for defining custom index name.
NowFunc is the type of function that returns the current time.
Offset Query.
OnDelete option for foreign key.
OnUpdate option for foreign key.
Optional option.
Options options for table, column and index.
Precision defines the precision for the decimal fields, representing the total number of digits in the number.
Preload query.
Primary set column as primary.
Raw string.
Reload force reload after insert/update.
Required disallows nil values in the column.
Scale Defines the scale for the decimal fields, representing the number of digits after the decimal point.
SchemaOp type.
Unique set column as unique.
Unscoped query.
Unsigned sets integer column to be unsigned.