postgres

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 18 Imported by: 5

README

Postgres

Usage

Add import in deploy src file.

import (
	_ "github.com/aacfactory/fns-contrib/databases/postgres/dialect"
)

Use github.com/aacfactory/fns-contrib/databases/postgres insteadof github.com/aacfactory/fns-contrib/databases/sql/dac.


entry, err = postgres.Insert[Table](ctx, entry)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ALL added in v1.0.0

func ALL[T Table](ctx context.Context, options ...QueryOption) (entries []T, err error)

func Asc

func Asc(name string) orders.Orders

func Between

func Between(field string, left any, right any) conditions.Condition

func Bool added in v1.0.0

func Bool(b bool) conditions.Literal

func ContainsJsonKey added in v0.12.6

func ContainsJsonKey(field string, key string) conditions.Condition

func ContainsJsonObject added in v0.12.6

func ContainsJsonObject(field string, object json.RawMessage) conditions.Condition

func ContainsJsonObjectOfArray added in v0.12.6

func ContainsJsonObjectOfArray(field string, object json.RawMessage) conditions.Condition

func ContainsJsonObjectsOfArray added in v0.12.6

func ContainsJsonObjectsOfArray(field string, all bool, elements ...any) conditions.Condition

func Count

func Count[T Table](ctx context.Context, cond conditions.Condition) (count int64, err error)

func Delete

func Delete[T Table](ctx context.Context, entry T) (v T, affected int64, err error)

func DeleteByCondition added in v1.0.0

func DeleteByCondition[T Table](ctx context.Context, cond conditions.Condition) (affected int64, err error)

func Desc

func Desc(name string) orders.Orders

func Eq

func Eq(field string, expression any) conditions.Condition

func Exist

func Exist[T Table](ctx context.Context, cond conditions.Condition) (has bool, err error)

func FAG added in v1.0.0

func Float added in v1.0.0

func Float(f float32) conditions.Literal

func Float64 added in v1.0.0

func Float64(f float64) conditions.Literal

func Gt added in v1.0.0

func Gt(field string, expression any) conditions.Condition

func Gte added in v1.0.0

func Gte(field string, expression any) conditions.Condition

func In added in v1.0.0

func In(field string, expression ...any) conditions.Condition

func Insert

func Insert[T Table](ctx context.Context, entry T) (v T, ok bool, err error)

func InsertMulti added in v1.0.0

func InsertMulti[T Table](ctx context.Context, entries []T) (affected int64, err error)

func InsertOrUpdate

func InsertOrUpdate[T Table](ctx context.Context, entry T) (v T, err error)

func InsertWhenExist

func InsertWhenExist[T Table](ctx context.Context, entry T, source conditions.QueryExpr) (v T, err error)

func InsertWhenNotExist

func InsertWhenNotExist[T Table](ctx context.Context, entry T, source conditions.QueryExpr) (v T, err error)

func Int added in v1.0.0

func Int(n int) conditions.Literal

func Int64 added in v1.0.0

func Int64(n int64) conditions.Literal

func Like

func Like(field string, expression string) conditions.Condition

func LikeContains added in v1.0.0

func LikeContains(field string, expression string) conditions.Condition

func LikeLast added in v1.0.0

func LikeLast(field string, expression string) conditions.Condition

func Lit added in v0.12.6

func Lit(v string) conditions.Literal

func LitSubQuery added in v1.0.0

func LitSubQuery(query string) conditions.QueryExpr

func Lt added in v1.0.0

func Lt(field string, expression any) conditions.Condition

func Lte added in v1.0.0

func Lte(field string, expression any) conditions.Condition

func Named added in v1.0.0

func Named(name string, value any) sql.NamedArg

func New added in v1.0.0

func New(options ...sql.Option) services.Service

func NotEq

func NotEq(field string, expression any) conditions.Condition

func NotIn added in v0.11.2

func NotIn(field string, expression ...any) conditions.Condition

func One added in v1.0.0

func One[T Table](ctx context.Context, options ...QueryOption) (entry T, has bool, err error)

func Page

func Page[T Table](ctx context.Context, no int, size int, options ...QueryOption) (page dac.Pager[T], err error)

func Query

func Query[T Table](ctx context.Context, offset int, length int, options ...QueryOption) (entries []T, err error)

func String added in v1.0.0

func String(s string) conditions.Literal

func SubQuery added in v0.12.8

func SubQuery(query any, field string, cond conditions.Condition) conditions.QueryExpr

func Time added in v1.0.0

func Time(t time.Time) conditions.Literal

func Tree added in v1.0.0

func Tree[T Table](ctx context.Context, options ...QueryOption) (entry T, err error)

func Trees added in v1.0.0

func Trees[T Table](ctx context.Context, options ...QueryOption) (entries []T, err error)

func Uint added in v1.0.0

func Uint(n uint) conditions.Literal

func Uint64 added in v1.0.0

func Uint64(n uint64) conditions.Literal

func Update added in v1.0.0

func Update[T Table](ctx context.Context, entry T) (v T, affected int64, err error)

func UpdateFields added in v1.0.0

func UpdateFields[T Table](ctx context.Context, fields FieldValues, cond conditions.Condition) (affected int64, err error)

func Use added in v1.0.0

func Use(ctx context.Context, endpointName []byte) context.Context

func WithDatabase added in v1.0.0

func WithDatabase(db databases.Database) sql.Option

func WithName added in v1.0.0

func WithName(name string) sql.Option

Types

type FieldValues added in v1.0.0

type FieldValues dac.FieldValues

func Field added in v1.0.0

func Field(name string, value any) FieldValues

func (FieldValues) Field added in v1.0.0

func (fields FieldValues) Field(name string, value any) FieldValues

type QueryOption added in v1.0.0

type QueryOption dac.QueryOption

func Conditions

func Conditions(cond conditions.Condition) QueryOption

func GroupBy added in v1.0.0

func GroupBy(fields ...string) QueryOption

func Having added in v1.0.0

func Having(cond conditions.Condition) QueryOption

func Orders

func Orders(order orders.Orders) QueryOption

type QueryOptions added in v1.0.0

type QueryOptions struct {
	dac.QueryOption
}

type Table

type Table interface {
	dac.Table
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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