Categorygithub.com/veertech/go-kallax
modulepackage
0.13.0
Repository: https://github.com/veertech/go-kallax.git
Documentation: pkg.go.dev

# README

Kallax - PostgreSQL ORM for Go

GoDoc Build Status codecov Go Report Card License: MIT

Installation

The recommended way to install kallax is:

go get -u github.com/src-d/kallax/...

kallax includes a binary tool used by go generate, please be sure that $GOPATH/bin is on your $PATH

Running tests

For obvious reasons, an instance of PostgreSQL is required to run the tests of this package.

By default, it assumes that an instance exists at 0.0.0.0:5432 with an user, password and database name all equal to testing.

If that is not the case you can set the following environment variables:

  • DBNAME: name of the database
  • DBUSER: database user
  • DBPASS: database user password

License

MIT, see LICENSE

# Packages

Package generator implements the processor of source code and generator of kallax models based on Go source code.
IMPORTANT! This is auto generated code by https://github.com/src-d/go-kallax Please, do not touch the code below, and if you do, do it under your own risk.
Package types provides implementation of some wrapper SQL types.

# Functions

And returns the given conditions joined by logical ands.
ApplyAfterEvents calls all the update, insert or save after events of the record.
ApplyBeforeEvents calls all the update, insert or save before events of the record.
ArrayContainedBy returns a condition that will be true when `col` has all its elements present in the given values.
ArrayContains returns a condition that will be true when `col` contains all the given values.
ArrayEq returns a condition that will be true when `col` is equal to an array with the given elements.
ArrayGt returns a condition that will be true when all elements in `col` are greater or equal than their counterparts in the given values, and one of the elements at least is greater than its counterpart in the given values.
ArrayGtOrEq returns a condition that will be true when all elements in `col` are greater or equal than their counterparts in the given values.
ArrayLt returns a condition that will be true when all elements in `col` are lower or equal than their counterparts in the given values, and one of the elements at least is lower than its counterpart in the given values.
ArrayLtOrEq returns a condition that will be true when all elements in `col` are lower or equal than their counterparts in the given values.
ArrayNotEq returns a condition that will be true when `col` is not equal to an array with the given elements.
ArrayOverlap returns a condition that will be true when `col` has elements in common with an array formed by the given values.
Asc returns a column ordered by ascending order.
AtJSONPath returns the schema field to query an arbitrary JSON element at the given path.
ColumnNames returns the names of the given schema fields.
Desc returns a column ordered by descending order.
Eq returns a condition that will be true when `col` is equal to `value`.
Gt returns a condition that will be true when `col` is greater than `value`.
GtOrEq returns a condition that will be true when `col` is greater than `value` or equal.
In returns a condition that will be true when `col` is equal to any of the passed `values`.
JSONContainedBy returns a condition that will be true when `col` is contained by the given element converted to JSON.
JSONContains returns a condition that will be true when `col` contains the given element converted to JSON.
JSONContainsAllKeys returns a condition that will be true when `col` contains all the given keys.
JSONContainsAny returns a condition that will be true when `col` contains any of the given elements converted to json.
JSONContainsAnyKey returns a condition that will be true when `col` contains any of the given keys.
JSONIsArray returns a condition that will be true when `col` is a JSON array.
JSONIsObject returns a condition that will be true when `col` is a JSON object.
Lt returns a condition that will be true when `col` is lower than `value`.
LtOrEq returns a condition that will be true when `col` is lower than `value` or equal.
Neq returns a condition that will be true when `col` is not `value`.
NewBaseQuery creates a new BaseQuery for querying the table of the given schema.
NewBaseSchema creates a new schema with the given table, alias, identifier and columns.
NewBatchingResultSet returns a new result set that performs batching underneath.
NewForeignKey creates a new Foreign key with the given name.
NewJSONSchemaArray creates a new SchemaField that is a json array.
NewJSONSchemaKey creates a new SchemaField that is a json key.
NewModel creates a new Model that is writable and not persisted.
NewResultSet creates a new result set with the given rows and columns.
NewSchemaField creates a new schema field with the given name.
NewStore returns a new Store instance.
NewULID returns a new ULID, which is a lexically sortable UUID.
Not returns the given condition negated.
NotIn returns a condition that will be true when `col` is distinct to all of the passed `values`.
Or returns the given conditions joined by logical ors.
RecordValues returns the values of a record at the given columns in the same order as the columns.
VirtualColumn returns a sql.Scanner that will scan the given column as a virtual column in the given record.

# Constants

JSONAny represents a type that can't be casted.
JSONBool is a boolean json type.
JSONFloat is a floating point json type.
JSONInt is a numeric json type.
JSONText is a text json type.
ManyToMany is a relationship between many records on both sides of the relationship.
OneToMany is a relationship between one record in a table and multiple in another table.
OneToOne is a relationship between one record in a table and another in another table.

# Variables

ErrCantSetID is returned when a model is inserted and it does not have neither an autoincrement primary key nor implements the IDSetter interface.
ErrEmptyID a document without ID cannot be used with Save method.
ErrInvalidTxCallback is returned when a nil callback is passed.
ErrManyToManyNotSupported is returned when a many to many relationship is added to a query.
ErrNewDocument a new documents cannot be updated.
ErrNonNewDocument non-new documents cannot be inserted.
ErrNoRowUpdate is returned when an update operation does not affect any rows, meaning the model being updated does not exist.
ErrNotFound is returned when a certain entity is not found.
ErrNotWritable is returned when a record is not writable.
ErrRawScan is an error returned when a the `Scan` method of `ResultSet` is called with a `ResultSet` created as a result of a `RawQuery`, which is not allowed.
ErrRawScanBatching is an error returned when the `RawScan` method is used with a batching result set.
ErrStop can be returned inside a ForEach callback to stop iteration.

# Structs

BaseQuery is a generic query builder to build queries programmatically.
BaseResultSet is a generic collection of rows.
BaseSchema is the basic implementation of Schema.
BaseSchemaField is a basic schema field with name.
BatchingResultSet is a result set that retrieves all the items up to the batch size set in the query.
ForeignKey contains the schema field of the foreign key and if it is an inverse foreign key or not.
JSONSchemaArray is a SchemaField that represents a JSON array.
JSONSchemaKey is a SchemaField that represents a key in a JSON object.
Model contains all the basic fields that make something a model, that is, the ID and some internal data used by kallax.
RecordWithSchema is a structure that contains both a record and its schema.
Relationship is a relationship with its schema and the field of te relation in the record.
Store is a structure capable of retrieving records from a concrete table in the database.
Timestamps contains the dates of the last time the model was created or deleted.

# Interfaces

AfterDeleter will do some operations after being deleted.
AfterInserter will do some operations after being inserted.
AfterSaver will do some operations after being inserted or updated.
AfterUpdater will do some operations after being updated.
ArraySchemaField is an interface that defines if a field is a JSON array.
BeforeDeleter will do some operations before being deleted.
BeforeInserter will do some operations before being inserted.
BeforeSaver will do some operations before being updated or inserted.
BeforeUpdater will do some operations before being updated.
ColumnAddresser provides the pointer addresses of columns.
ColumnOrder represents a column name with its order.
Identifiable must be implemented by those values that can be identified by an ID.
Identifier is a type used to identify a model.
Persistable must be implemented by those values that can be persisted.
Query is the common interface all queries must satisfy.
Record is something that can be stored as a row in the database.
Relationable can perform operations related to relationships of a record.
ResultSet is the common interface all result sets need to implement.
Schema represents a table schema in the database.
SchemaField is a named field in the table schema.
Valuer provides the values for columns.
VirtualColumnContainer contains a collection of virtual columns and manages them.
Writable must be implemented by those values that defines internally if they can be sent back to the database to be stored with its changes.

# Type aliases

Condition represents a condition of filtering in a query.
ForeignKeys is a mapping between relationships and their foreign key field.
JSONKeyType is the type of an object key in a JSON.
NumericID is a wrapper for int64 that implements the Identifier interface.
RecordConstructor is a function that creates a record.
RelationshipType describes the type of the relationship.
ULID is an ID type provided by kallax that is a lexically sortable UUID.
UUID is a wrapper type for uuid.UUID that implements the Identifier interface.