weasel

package module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2022 License: MIT Imports: 8 Imported by: 0

README

Weasel

Note: Weasel is just now reaching a stable API. Most necessary features are available or easily integratable. You may still expect a few API changes, but the majority should be usable.

  1. About
  2. API
  3. Documentation
  4. Roadmap
  5. License

About

Weasel is the last ORM for Golang you'll ever need. Built with Generics, so it requires at least Go 1.18+.

API

See the docs

Documentation

Here's an example of the API:

package main

import (
  "github.com/ztcollazo/weasel" // Main package
  "github.com/ztcollazo/weasel/use" // Use package contains middleware and validations
  "github.com/lib/pq" // Or whatever db you're using
)

func main() {
  // Connect is a wrapper around SQLX's connect; see that for more details.
  conn := weasel.Connect("postgres", "user=foo dbname=bar sslmode=off")

  // Let's create the schema now
  type PersonSchema struct {
    weasel.Document[*PersonSchema] // Note the pointer!!!
    // PK denotes it as the primary key
    Id        int                            `db:"id" pk:"" type:"serial"`
    FirstName string                         `db:"first_name" type:"text"`
    LastName  string                         `db:"last_name" type:"text"`
    Email     string                         `db:"email" type:"text"`
    PlaceId   int                            `db:"place_id" type:"integer"`
    // Relations
    Place     weasel.BelongsTo[*PlaceSchema] `belongsto:"place"` // Again with the required pointer
    Hello     string
  }

  // You can define an `Init` function that is called whenever a document is created.
  // Again, the method MUST have a pointer receiver.
  func (p *PersonSchema) Init() {
    p.Hello = "world"
    // Relations, supports: BelongsTo, HasMany (and through), HasOne
    // Note: This format has been changed.
    // Old: weasel.UseBelongsTo(p, Place)
    p.Use(use.BelongsTo[*PersonSchema](Place))

    // The other relations are fairly straightforward:
    // HasOne is basically the same as BelongsTo
    // HasMany is a Group (see below)
    // HasMany through is slightly different
    // In that case, you would still use the HasMany function
    // But in the schema, you would add a `through` tag
    // with the intermittent model


    // this is also where you would do your validations
    // d.Errors is an []error
    if p.FirstName == "" {
      p.AddError(errors.New("missing first name"))
    }
    // or
    p.Use(use.ValidatePresenceOf[string /* validate presence requires data type */]("first_name"))
    // Also supports:
    // Custom: Validates(field, func(val type) bool)
    // Unique: ValidatesUniquenessOf(field)
    // Format: ValidatesFormatOf(field, regexp)
  }

  // Now for the fun part
  // Types are inferred from the second parameter; it's only there so that we can copy it
  Person := weasel.Create(conn, &PersonSchema{}, "person") // returns *Model[*PersonSchema]

  // Or you can define an init (or multiple) function also
  Person := weasel.Create(conn, &PersonSchema, "person", func (m *Model[*PersonSchema]) {
    // You can define properties on the model
    m.Set("key", "value")
    m.Get("key") //=> "value"
  })

  // Done! use it like you would Active Record
  p, _ := Person.Find(1)
  p.FirstName // 🤯 🥳
  p.Hello //=> "world"

  john, err /* error handling also */ = Person.Create(&PersonSchema{
    FirstName: "John",
    LastName: "Doe",
    Email: "john@doe.com",
    PlaceId: 1,
  })

  john.Email //=> john@doe.com

  john.Email = "johndoe@whatever.com"
  john.Save() // Pretty intuitive

  // And then when you're done
  john.Delete()

  // You can also do batch queries
  people, _ := Person.All().Where(weasel.Eq{"first_name": "John"}).Limit(3).Offset(6).Exec() // For built queries, make sure that you append exec.
  // people => []*PersonSchema{...}

  // Or specific queries
  jane := Person.FindBy("first_name", "Jane")

  // Now let's get the place
  jane.Place() //=> *PlaceSchema{...}

  // You can also check if a document is valid
  jane.IsValid() //=> true
  jane.FirstName = ""
  jane.IsValid() //=> false
  jane.IsInvalid() //=> true

  // You can add groups to group together documents with certain properties
  Person.AddGroup("FromUS", weasel.Eq{"place_id": 1})

  // And now
  Person.FromGroup("FromUS").All().Exec() // Same API as Model
  // To learn more about groups, please see below

  // You can do many other useful features such as:
  Person.Exists(1)
  Person.First() // Up to fifth
  Person.Last() // up to second
  Person.Nth(7)
  Person.NthFromLast(3)
  // To change to order of the documents, you can do:
  Person.Order("first_name DESC") // Etc.

  // You can also serialize documents:
  p, _ := Person.First()
  json, _ := Person.ToJSON()
  // Or for custom serialization:
  mp := p.ToMap() // Creates a map of all of the fields
}
On the topic of Groups

Groups are an extremely valuable feature in ORMs. They allow you to combine documents with similar features, all without having to repeat your queries over and over. Groups in weasel are the foundation of not only themselves, but also models. A few rules:

  1. Groups depend on models

Models are what give groups the data about the table itself. This is not left to the groups.

  1. Models depend on groups

If you look in the code, you will find that Model[Doc] actually extends *Group[Doc]. This is interesting, because that means that, while models give groups all of the data, groups give models all of the functionality.

Roadmap

  • Connection + multiple drivers
  • Query builder
  • Create
  • Read
  • Update
  • Delete
  • Relations
  • Validations
    • Check valid
    • Errors
    • Validate Presence
    • Validate Format
    • Validate Custom
    • Validate Uniqueness
  • Model Groups
  • Model utilities
    • Find nth document
    • Find nth to last document
    • Check if document exists
    • Count of documents
    • Serialize documents
  • CLI?
    • Create model files
    • Migrations?
  • Better config format

...and any that may come up in the future.

License

Weasel is licensed under the MIT license. View the LICENSE.txt for more information.

Documentation

Overview

Weasel is an all-purpose, powerful ORM for Golang built on Generics. It has the feel of Active Record, and much of the same functionality. See the README for a detailed explanation of Weasel and its abilities, or you can check out the test suite to see examples of many of its functions.

Weasel currently supports Models, Documents, Groups, Relations, Model properties, Validations, Query building, Error handling, and many common utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UseBelongsTo deprecated added in v0.3.0

func UseBelongsTo[Doc document[Doc], Rel document[Rel]](doc Doc, model *Model[Rel])

UseBelongsTo populates the field that returns the belongs to relationship, specified in the schema. It takes a document and the model that the document belongs to.

Deprecated: the use package now contains the functions HasMany, BelongsTo, and HasOne to take the place of UseHasMany, UseBelongsTo, and UseHasOne. These functions follow the middleware format. These will be removed in a later release. You may still use the types provided in the main package.

func UseHasMany deprecated added in v0.3.0

func UseHasMany[Doc document[Doc], Rel document[Rel]](doc Doc, model *Model[Rel])

Use has many populates the field that returns the has many relationship, specified in the schema. It takes a document and the model that the document has many of.

Deprecated: the use package now contains the functions HasMany, BelongsTo, and HasOne to take the place of UseHasMany, UseBelongsTo, and UseHasOne. These functions follow the middleware format. These will be removed in a later release. You may still use the types provided in the main package.

func UseHasOne deprecated added in v0.3.0

func UseHasOne[Doc document[Doc], Rel document[Rel]](doc Doc, model *Model[Rel])

UseHasOne populates the field that returns the has one relationship, specified in the schema. it takes a document and the model that the document has one of.

Deprecated: the use package now contains the functions HasMany, BelongsTo, and HasOne to take the place of UseHasMany, UseBelongsTo, and UseHasOne. These functions follow the middleware format. These will be removed in a later release. You may still use the types provided in the main package.

Types

type And added in v0.2.1

type And = sq.And

type BelongsTo added in v0.3.0

type BelongsTo[Doc document[Doc]] func() (Doc, error)

Type BelongsTo is the type used to represent the flipside of a one-to-many relationship in a schema. Use the following struct tags to give it more information:

  • key: default is the primary key. This is the column that the foreign key points to.
  • fk: the name of the foreign key column.
  • belongsto: the table that it belongs to.

type Connection

type Connection struct {
	Builder sq.StatementBuilderType
	DB      *sqlx.DB
	// contains filtered or unexported fields
}

Connection holds all of the connection information, to be used in the models. It also contains the configured raw query builder and DB API, which both are not recommended to directly be used, but are useful if you need a complex query that is not officially supported. The query builder type comes from Squirrel, and the DB type is sqlx.DB.

func Connect

func Connect(driver string, opts string) Connection

The connect function creates a connection to the database. The opts string as the second parameter is a direct wrapper of sqlx.Connect; see sqlx's documentation for more details.

type Document added in v0.2.0

type Document[Doc document[Doc]] struct {
	Model  *Model[Doc]
	Errors []error
	// contains filtered or unexported fields
}

Document provides a struct to extend your schemas. It contains errors and model information and extends DocumentBase. You typically will not have to use Document except for in defining your schema, for example:

type PersonSchema struct {
	weasel.Document[*PersonSchema]
}

func (*Document[Doc]) AddError added in v0.4.0

func (d *Document[Doc]) AddError(es error)

You can use AddError to append an error to the list. This is very useful in middleware.

func (Document[Doc]) AllErrors added in v0.5.1

func (d Document[Doc]) AllErrors() []error

AllErrors returns all of the document's errors.

func (Document[Doc]) Conn added in v0.4.0

func (d Document[Doc]) Conn() Connection

Conn returns the current connection. See the connection docs.

func (*Document[Doc]) Create added in v0.3.0

func (d *Document[Doc]) Create(doc Doc, model *Model[Doc])

This is an internal function, exported only for use with reflect Do not use.

func (Document[Doc]) Delete added in v0.2.0

func (d Document[Doc]) Delete() error

Delete completely removes the document from the database.

func (Document[Doc]) Error added in v0.5.1

func (d Document[Doc]) Error(id int) error

Error returns the error at the given ID.

func (Document[Doc]) Get added in v0.2.0

func (d Document[Doc]) Get(name string) any

Get returns a property (DB or struct) on the document. You may need to use type assertion.

func (Document[Doc]) GetModel added in v0.6.2

func (d Document[Doc]) GetModel() *Model[Doc]

func (Document[Doc]) Init added in v0.2.0

func (d Document[Doc]) Init()

You can define a custom Init function to run on document creation.

func (Document[Doc]) IsInvalid added in v0.3.2

func (d Document[Doc]) IsInvalid() bool

IsInvalid checks if the document has any errors.

func (Document[Doc]) IsValid added in v0.3.2

func (d Document[Doc]) IsValid() bool

IsValid checks that the document does not contain any errors.

func (Document[Doc]) PrimaryKey added in v0.4.0

func (d Document[Doc]) PrimaryKey() string

PrimaryKey returns the table's primary key. This is useful for middleware.

func (*Document[Doc]) RemoveError added in v0.5.1

func (d *Document[Doc]) RemoveError(id int)

RemoveError takes the index of an error and removes it from the list.

func (Document[Doc]) Save added in v0.2.0

func (d Document[Doc]) Save() error

Save saves the document's changes, changed either by Set or manually.

func (Document[Doc]) Set added in v0.2.0

func (d Document[Doc]) Set(name string, value any)

Set sets a property on the document (DB or struct).

func (*Document[Doc]) SetErrors added in v0.5.1

func (d *Document[Doc]) SetErrors(errs []error)

SetErrors completely sets all of the errors. It is not recommended to use unless you really need to or want to reset all of the errors.

func (Document[Doc]) Table added in v0.4.0

func (d Document[Doc]) Table() string

Table returns the table name of the document. This is useful for middleware.

func (Document[Doc]) ToJSON added in v0.6.3

func (d Document[Doc]) ToJSON() (string, error)

ToJSON returns a JSON string of all of the document's fields. This is useful for serialization in HTTP responses.

func (Document[Doc]) ToMap added in v0.6.3

func (d Document[Doc]) ToMap() map[string]any

ToMap returns a map of the document. This is useful for custom serialization.

func (*Document[Doc]) Use added in v0.4.0

func (d *Document[Doc]) Use(m Middleware)

Use takes middleware and runs it on document creation.

type DocumentBase added in v0.4.0

type DocumentBase interface {
	Delete() error
	Save() error
	ToJSON() (string, error)
	ToMap() map[string]any
	Get(string) any
	Set(string, any)
	AllErrors() []error
	AddError(error)
	SetErrors([]error)
	RemoveError(int)
	Error(int) error
	PrimaryKey() string
	Init()
	IsValid() bool
	IsInvalid() bool
	Table() string
	Conn() Connection
	Use(Middleware)
}

DocumentBase provides an interface to be used for times when you may not know the schema type. All documents conform to it; it is used as the constraint for type parameters. You may find yourself using DocumentBase if you want to write custom validation and middleware.

type Eq added in v0.2.1

type Eq = sq.Eq

type Field

type Field struct {
	Name       string
	DBName     string
	Type       string
	Default    string
	NotNil     bool
	PrimaryKey bool
}

Type field represents the field structure used internally for field metadata, provided by struct tags.

type Group added in v0.5.0

type Group[Doc DocumentBase] struct {
	Where whereable
	Model *Model[Doc]
	// contains filtered or unexported fields
}

Group is the foundation on both Model and Group functionality. It has many of the methods used in the model, and contains all of the querying utilities.

func NewGroupWith added in v0.7.0

func NewGroupWith[Doc DocumentBase](where whereable, model *Model[Doc], innerJoin, on, id, order string, groups map[string]*Group[Doc]) *Group[Doc]

func (Group[Doc]) All added in v0.5.0

func (m Group[Doc]) All() SelectManyQuery[Doc]

All returns all of the documents in the group or model. It returns a query builder that contains functions including Where, OrderBy, GroupBy. For more information and functions, see SelectManyQuery and its methods.

func (Group[Doc]) Count added in v0.6.0

func (m Group[Doc]) Count() (int, error)

Count returns the number of documents in the group or model.

func (Group[Doc]) Create added in v0.5.2

func (m Group[Doc]) Create(d Doc) (Doc, error)

Create creates a document and adds it to the database TODO: Make create conform to `where` clause

func (*Group[Doc]) CreateGroup added in v0.6.0

func (m *Group[Doc]) CreateGroup(name string, expr whereable)

CreateGroup adds a group to the model or group that can be accessed by FromGroup. It respects the current group's where clause and contains all of the querying functionality and utilities.

func (Group[Doc]) Exists added in v0.6.0

func (m Group[Doc]) Exists(id any) (bool, error)

Exists checks if the document with the given primary key exists.

func (Group[Doc]) Fifth added in v0.6.0

func (m Group[Doc]) Fifth() (Doc, error)

Fifth returns the fifth document. See Nth for more information.

func (Group[Doc]) Find added in v0.5.0

func (m Group[Doc]) Find(value any) (Doc, error)

Find takes the primary key value and finds the corresponding document.

func (Group[Doc]) FindBy added in v0.5.0

func (m Group[Doc]) FindBy(name string, value any) (Doc, error)

FindBy takes a column name and value and finds the corresponding document. If you want to find multiple, use All().Where(weasel.Eq{key: value}).

func (Group[Doc]) First added in v0.6.0

func (m Group[Doc]) First() (Doc, error)

First returns the first document from the table, via the set order clause. See Nth for more information.

func (Group[Doc]) Fourth added in v0.6.0

func (m Group[Doc]) Fourth() (Doc, error)

Fourth returns the fourth document. See Nth for more information.

func (Group[Doc]) FromGroup added in v0.6.0

func (m Group[Doc]) FromGroup(name string) *Group[Doc]

FromGroup returns the group that the name parameter points to. See CreateGroup() and Group for more information.

func (*Group[Doc]) GetOrder added in v0.6.2

func (m *Group[Doc]) GetOrder() string

Get order returns the order of the documents used when queried, for example "id ASC"

func (Group[Doc]) Last added in v0.6.0

func (m Group[Doc]) Last() (Doc, error)

Last returns the last document in the table, via the opposite of order. See NthToLast for more information.

func (Group[Doc]) Nth added in v0.6.0

func (m Group[Doc]) Nth(id int) (Doc, error)

Nth returns the document at the given index. For example:

Person.Nth(6) // Returns the sixth document.

func (Group[Doc]) NthToLast added in v0.6.0

func (m Group[Doc]) NthToLast(id int) (Doc, error)

NthToLast returns the last document at the given index. For example:

Person.NthToLast(3) // Returns the third to last document.

func (*Group[Doc]) Order added in v0.6.0

func (m *Group[Doc]) Order(by string)

Order sets the order that the documents should be sorted by when queried.

func (Group[Doc]) Second added in v0.6.0

func (m Group[Doc]) Second() (Doc, error)

Second returns the second document. See Nth for more information.

func (Group[Doc]) SecondToLast added in v0.6.0

func (m Group[Doc]) SecondToLast() (Doc, error)

SecondToLast returns the second to last document in the table. See NthToLast for more information.

func (Group[Doc]) Third added in v0.6.0

func (m Group[Doc]) Third() (Doc, error)

Third returns the third document. See Nth for more information.

type Gt added in v0.2.1

type Gt = sq.Gt

type GtOrEq added in v0.2.1

type GtOrEq = sq.GtOrEq

type HasMany added in v0.3.0

type HasMany[Doc document[Doc]] func() *Group[Doc]

Type HasMany is the type used to represent a one-to-many or many-to-many relationship in a schema. Use the following struct tags to give it more information:

  • key: default is the primary key. This is the column that the foreign key points to.
  • fk: the name of the foreign key column.
  • through: the join table for many-to-many relationships.
  • hasmany: the table that it has many of.

type HasOne added in v0.3.0

type HasOne[Doc document[Doc]] func() (Doc, error)

Type HasMany is the type used to represent a one-to-one relationship in a schema. Use the following struct tags to give it more information:

  • key: default is the primary key. This is the column that the foreign key points to.
  • fk: the name of the foreign key column.
  • hasone: the table that it has one of.

type ILike added in v0.2.1

type ILike = sq.ILike

type Init added in v0.6.0

type Init[Doc document[Doc]] func(*Model[Doc])

Type Init represents the init function passed to Create

type InsertQuery

type InsertQuery[Doc DocumentBase] struct {
	// contains filtered or unexported fields
}

InsertQuery builds an insert sql query. See squirrel's docs for some of the functions. Note: InsertQuery does not include all of squirrel's functions. It handles some of the internally.

func Insert

func Insert[Doc DocumentBase](model *Model[Doc]) InsertQuery[Doc]

Insert takes a model and builds an insert query. You can set the columns and values. Finally, call Exec() to run the query.

func (InsertQuery[Doc]) Columns

func (i InsertQuery[Doc]) Columns(columns ...string) InsertQuery[Doc]

func (InsertQuery[Doc]) Exec

func (i InsertQuery[Doc]) Exec() (Doc, error)

func (InsertQuery[Doc]) Options

func (i InsertQuery[Doc]) Options(options ...string) InsertQuery[Doc]

func (InsertQuery[Doc]) Values

func (i InsertQuery[Doc]) Values(values ...any) InsertQuery[Doc]

type Like added in v0.2.1

type Like = sq.Like

type Lt added in v0.2.1

type Lt = sq.Lt

type LtOrEq added in v0.2.1

type LtOrEq = sq.LtOrEq

type Middleware added in v0.4.0

type Middleware func(DocumentBase)

Middleware is a type that all middleware (passed to the Use function) should be/return. it takes an argument in DocumentBase and can use `Get` and `Set` to get and change properties.

type Model

type Model[Doc DocumentBase] struct {
	*Group[Doc]
	Conn Connection
	// contains filtered or unexported fields
}

Model is the model itself. It extends Group and has all of Group's functionality, and more. It also provides the table metadata to Group.

func Create

func Create[Doc document[Doc]](conn Connection, ex Doc, name string, inits ...Init[Doc]) *Model[Doc]

Create creates a model from the given connection, document, table name, and initializers.

func (Model[Doc]) Get added in v0.6.0

func (m Model[Doc]) Get(key string) any

Get returns a value set by Set.

func (Model[Doc]) Name added in v0.6.2

func (m Model[Doc]) Name() string

Name returns the table name of the model.

func (Model[Doc]) Relations added in v0.6.2

func (m Model[Doc]) Relations() map[string]Relation

Relations returns the map of relations used internally by weasel.

func (*Model[Doc]) Set added in v0.6.0

func (m *Model[Doc]) Set(key string, val any)

Set sets a value on the model.

type NotEq added in v0.2.1

type NotEq = sq.NotEq

type NotILike added in v0.2.1

type NotILike = sq.NotILike

type NotLike added in v0.2.1

type NotLike = sq.NotLike

type Or added in v0.2.1

type Or = sq.Or

type Relation added in v0.3.0

type Relation struct {
	Name       string
	Variant    string
	Key        string
	ForeignKey string
	Table      string
	Through    string
}

Type relation represents a relation's metadata, provided by struct tags.

type SelectManyQuery

type SelectManyQuery[Doc DocumentBase] struct {
	// contains filtered or unexported fields
}

SelectManyQuery builds an select sql query. See squirrel's docs for some of the functions. Note: SelectManyQuery does not include all of squirrel's functions. It handles some of the internally.

func SelectMany

func SelectMany[Doc DocumentBase](columns []string, model *Model[Doc]) SelectManyQuery[Doc]

SelectMany builds a select query. Pass in the columns and model, and when you are done building the query, call the Exec() function to run it.

func (SelectManyQuery[Doc]) Column

func (s SelectManyQuery[Doc]) Column(column any, args ...any) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) Columns

func (s SelectManyQuery[Doc]) Columns(columns ...string) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) CrossJoin

func (s SelectManyQuery[Doc]) CrossJoin(join string, rest ...any) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) Distinct

func (s SelectManyQuery[Doc]) Distinct() SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) Exec

func (s SelectManyQuery[Doc]) Exec() ([]Doc, error)

func (SelectManyQuery[Doc]) GroupBy

func (s SelectManyQuery[Doc]) GroupBy(groupBys ...string) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) Having

func (s SelectManyQuery[Doc]) Having(pred any, rest ...any) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) InnerJoin

func (s SelectManyQuery[Doc]) InnerJoin(join string, rest ...any) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) Join

func (s SelectManyQuery[Doc]) Join(join string, rest ...any) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) JoinClause

func (s SelectManyQuery[Doc]) JoinClause(pred any, rest ...any) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) LeftJoin

func (s SelectManyQuery[Doc]) LeftJoin(join string, rest ...any) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) Limit

func (s SelectManyQuery[Doc]) Limit(limit uint64) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) Offset

func (s SelectManyQuery[Doc]) Offset(offset uint64) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) Options

func (s SelectManyQuery[Doc]) Options(options ...string) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) OrderBy

func (s SelectManyQuery[Doc]) OrderBy(orderBys ...string) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) OrderByClause

func (s SelectManyQuery[Doc]) OrderByClause(pred any, args ...any) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) RightJoin

func (s SelectManyQuery[Doc]) RightJoin(join string, rest ...any) SelectManyQuery[Doc]

func (SelectManyQuery[Doc]) Where

func (s SelectManyQuery[Doc]) Where(pred any, args ...any) SelectManyQuery[Doc]

type SelectQuery

type SelectQuery[Doc DocumentBase] struct {
	// contains filtered or unexported fields
}

SelectQuery builds an select sql query. See squirrel's docs for some of the functions. Note: SelectQuery does not include all of squirrel's functions. It handles some of the internally.

func Select

func Select[Doc DocumentBase](columns []string, model *Model[Doc]) SelectQuery[Doc]

Select starts a select one query. It handles the internal table and column logic. You can pass the columns and model. When you are done building the query, call the Exec() function to run it.

func (SelectQuery[Doc]) Column

func (s SelectQuery[Doc]) Column(column any, args ...any) SelectQuery[Doc]

func (SelectQuery[Doc]) Columns

func (s SelectQuery[Doc]) Columns(columns ...string) SelectQuery[Doc]

func (SelectQuery[Doc]) CrossJoin

func (s SelectQuery[Doc]) CrossJoin(join string, rest ...any) SelectQuery[Doc]

func (SelectQuery[Doc]) Distinct

func (s SelectQuery[Doc]) Distinct() SelectQuery[Doc]

func (SelectQuery[Doc]) Exec

func (s SelectQuery[Doc]) Exec() (Doc, error)

func (SelectQuery[Doc]) GroupBy

func (s SelectQuery[Doc]) GroupBy(groupBys ...string) SelectQuery[Doc]

func (SelectQuery[Doc]) Having

func (s SelectQuery[Doc]) Having(pred any, rest ...any) SelectQuery[Doc]

func (SelectQuery[Doc]) InnerJoin

func (s SelectQuery[Doc]) InnerJoin(join string, rest ...any) SelectQuery[Doc]

func (SelectQuery[Doc]) Join

func (s SelectQuery[Doc]) Join(join string, rest ...any) SelectQuery[Doc]

func (SelectQuery[Doc]) JoinClause

func (s SelectQuery[Doc]) JoinClause(pred any, rest ...any) SelectQuery[Doc]

func (SelectQuery[Doc]) LeftJoin

func (s SelectQuery[Doc]) LeftJoin(join string, rest ...any) SelectQuery[Doc]

func (SelectQuery[Doc]) Limit

func (s SelectQuery[Doc]) Limit(limit uint64) SelectQuery[Doc]

func (SelectQuery[Doc]) Offset

func (s SelectQuery[Doc]) Offset(offset uint64) SelectQuery[Doc]

func (SelectQuery[Doc]) Options

func (s SelectQuery[Doc]) Options(options ...string) SelectQuery[Doc]

func (SelectQuery[Doc]) OrderBy

func (s SelectQuery[Doc]) OrderBy(orderBys ...string) SelectQuery[Doc]

func (SelectQuery[Doc]) OrderByClause

func (s SelectQuery[Doc]) OrderByClause(pred any, args ...any) SelectQuery[Doc]

func (SelectQuery[Doc]) RightJoin

func (s SelectQuery[Doc]) RightJoin(join string, rest ...any) SelectQuery[Doc]

func (SelectQuery[Doc]) Where

func (s SelectQuery[Doc]) Where(pred any, args ...any) SelectQuery[Doc]

Directories

Path Synopsis
Package use provides common utilities and validations for document, along with middleware for relations, to be used in the `Init` function of the schema.
Package use provides common utilities and validations for document, along with middleware for relations, to be used in the `Init` function of the schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL