where

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(fo, so model.Operation) model.Operation

Example

Where(
	where.And(
		where.Equals(&db.Animal.Status, "Eating"),
		where.Like(&db.Animal.Name, "%Cat%"),
	),
)

func Equals

func Equals[T any, A *T | **T](a A, v T) model.Operation

Example

// match Food with Id fc1865b4-6f2d-4cc6-b766-49c2634bf5c4
Where(where.Equals(&db.Food.Id, "fc1865b4-6f2d-4cc6-b766-49c2634bf5c4"))

// generate: WHERE "animals"."idhabitat" IS NULL
var idHabitat *string
Where(where.Equals(&db.Animal.IdHabitat, idHabitat))

func EqualsArg

func EqualsArg[T any, A *T | **T](a A, v A) model.Operation

Example

// implicit join using EqualsArg
goe.Select(db.Animal).
Where(
	where.And(
		where.EqualsArg[int](&db.Animal.Id, &db.AnimalFood.IdAnimal),
		where.EqualsArg[uuid.UUID](&db.Food.Id, &db.AnimalFood.IdFood),
	),
).AsSlice()

func Greater

func Greater[T any, A *T | **T](a A, v T) model.Operation

Example

// get all animals that was created after 09 of october 2024 at 11:50AM
Where(where.Greater(&db.Animal.CreateAt, time.Date(2024, time.October, 9, 11, 50, 00, 00, time.Local)))

func GreaterArg

func GreaterArg[T any, A *T | **T](a A, v A) model.Operation

Example

Where(where.GreaterArg(&db.Stock.Minimum, &db.Drinks.Stock))

func GreaterEquals

func GreaterEquals[T any, A *T | **T](a A, v T) model.Operation

Example

// get all animals that was created in or after 09 of october 2024 at 11:50AM
Where(where.GreaterEquals(&db.Animal.CreateAt, time.Date(2024, time.October, 9, 11, 50, 00, 00, time.Local)))

func GreaterEqualsArg

func GreaterEqualsArg[T any, A *T | **T](a A, v A) model.Operation

Example

Where(where.GreaterEqualsArg(&db.Drinks.Reorder, &db.Drinks.Stock))

func In

func In[T any, V []T | model.Query](a *T, mq V) model.Operation

Example

// where in using a slice
Where(where.In(&db.Animal.Name, []string{"Cat", "Dog"}))

// AsQuery for get the query result from a select query
querySelect := goe.Select[any](&struct{ Name *string }{Name: &db.Animal.Name}).AsQuery()

// Use querySelect on in
rows, err := goe.Select(db.Animal).Where(where.In(&db.Animal.Name, querySelect).AsSlice()

func Less

func Less[T any, A *T | **T](a A, v T) model.Operation

Example

// get all animals that was updated before 09 of october 2024 at 11:50AM
Where(where.Less(&db.Animal.UpdateAt, time.Date(2024, time.October, 9, 11, 50, 00, 00, time.Local)))

func LessArg

func LessArg[T any, A *T | **T](a A, v A) model.Operation

Example

Where(where.LessArg(&db.Exam.Score, &db.Data.Minimum))

func LessEquals

func LessEquals[T any, A *T | **T](a A, v T) model.Operation

Example

// get all animals that was updated in or before 09 of october 2024 at 11:50AM
Where(where.LessEquals(&db.Animal.UpdateAt, time.Date(2024, time.October, 9, 11, 50, 00, 00, time.Local)))

func LessEqualsArg

func LessEqualsArg[T any, A *T | **T](a A, v A) model.Operation

Example

Where(where.LessEqualsArg(&db.Exam.Score, &db.Data.Minimum))

func Like

func Like[T any](a *T, v string) model.Operation

Example

// get all animals that has a "at" in his name
Where(where.Like(&db.Animal.Name, "%at%"))

func NotEquals

func NotEquals[T any, A *T | **T](a A, v T) model.Operation

Example

// match all foods that name are not Cookie
Where(where.NotEquals(&db.Food.Name, "Cookie"))

// generate: WHERE "animals"."idhabitat" IS NOT NULL
var idHabitat *string
Where(where.NotEquals(&db.Animal.IdHabitat, idHabitat))

func NotEqualsArg

func NotEqualsArg[T any, A *T | **T](a A, v A) model.Operation

Example

Where(where.NotEqualsArg(&db.Job.Id, &db.Person.Id))

func NotIn

func NotIn[T any, V []T | model.Query](a *T, mq V) model.Operation

Example

// where not in using a slice
Where(where.NotIn(&db.Animal.Name, []string{"Cat", "Dog"}))

// AsQuery for get the query result from a select query
querySelect, err := goe.Select(&struct{ Name *string }{Name: &db.Animal.Name}).AsQuery()

// Use querySelect on not in
rows, err := goe.Select(db.Animal).Where(where.NotIn(&db.Animal.Name, querySelect).AsSlice()

func NotLike

func NotLike[T any](a *T, v string) model.Operation

Example

// get all animals that has a "at" in his name
Where(where.Like(&db.Animal.Name, "%at%"))

func Or

func Or(fo, so model.Operation) model.Operation

Example

Where(
	where.Or(
		where.Equals(&db.Animal.Status, "Eating"),
		where.Like(&db.Animal.Name, "%Cat%"),
	),
)

Types

This section is empty.

Jump to

Keyboard shortcuts

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