where

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 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() model.Operation

Example

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

func Equals

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

Example

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

// generate: WHERE "animals"."idhabitat" IS NULL
Wheres(where.Equals(&db.Animal.IdHabitat, nil))

func EqualsArg

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

Example

// implicit join using EqualsArg
goe.Select(db.Animal).
From(db.Animal, db.AnimalFood, db.Food).
Wheres(
	where.EqualsArg[int](&db.Animal.Id, &db.AnimalFood.IdAnimal),
	where.And(),
	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
Wheres(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

Wheres(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
Wheres(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

Wheres(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
Wheres(where.In(&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}).From(db.Animal).AsQuery()

// Use querySelect on in
rows, err := goe.Select(db.Animal).From(db.Animal).Wheres(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
Wheres(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

Wheres(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
Wheres(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

Wheres(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
Wheres(where.Like(&db.Animal.Name, "%at%"))

func NotEquals

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

Example

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

// generate: WHERE "animals"."idhabitat" IS NOT NULL
Wheres(where.NotEquals(&db.Animal.IdHabitat, nil))

func NotEqualsArg

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

Example

Wheres(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
Wheres(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}).From(db.Animal).AsQuery()

// Use querySelect on not in
rows, err := goe.Select(db.Animal).From(db.Animal).Wheres(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
Wheres(where.Like(&db.Animal.Name, "%at%"))

func Or

func Or() model.Operation

Example

Wheres(
	where.Equals(&db.Animal.Status, "Eating"),
	where.Or(),
	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