association

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: AGPL-3.0 Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Association

type Association struct {
	// contains filtered or unexported fields
}

Association represents a model association.

func NewAssociation

func NewAssociation(query contractsorm.Query, model any, association string) *Association

NewAssociation creates a new Association instance.

func (*Association) Append

func (a *Association) Append(values ...any) error

Append appending a model to the association.

func (*Association) AssociationName

func (a *Association) AssociationName() string

AssociationName returns the association name.

func (*Association) Clear

func (a *Association) Clear() error

Clear clears the association.

func (*Association) Count

func (a *Association) Count() int64

Count returns the number of records in the association.

func (*Association) Delete

func (a *Association) Delete(values ...any) error

Delete deletes the given value from the association.

func (*Association) Find

func (a *Association) Find(out any, conds ...any) error

Find finds records that match given conditions.

func (*Association) Model

func (a *Association) Model() any

Model returns the model instance.

func (*Association) Query

func (a *Association) Query() contractsorm.Query

Query returns the underlying query instance.

func (*Association) Replace

func (a *Association) Replace(values ...any) error

Replace replaces the association with the given value.

type BelongsTo

type BelongsTo struct {
	*Association
	// contains filtered or unexported fields
}

BelongsTo represents a belongs-to relationship.

func NewBelongsTo

func NewBelongsTo(query contractsorm.Query, model any, association, foreignKey, otherKey string) *BelongsTo

NewBelongsTo creates a new BelongsTo association.

func (*BelongsTo) Append

func (b *BelongsTo) Append(values ...any) error

Append sets the foreign key to associate the model.

func (*BelongsTo) Clear

func (b *BelongsTo) Clear() error

Clear clears the association by setting the foreign key to nil.

func (*BelongsTo) Count

func (b *BelongsTo) Count() int64

Count returns 1 if the association exists, 0 otherwise.

func (*BelongsTo) Delete

func (b *BelongsTo) Delete(values ...any) error

Delete clears the association by setting the foreign key to nil.

func (*BelongsTo) Find

func (b *BelongsTo) Find(out any, conds ...any) error

Find loads the associated model for a belongs-to relationship.

func (*BelongsTo) Replace

func (b *BelongsTo) Replace(values ...any) error

Replace replaces the current association with the given value.

type HasMany

type HasMany struct {
	*Association
	// contains filtered or unexported fields
}

HasMany represents a has-many relationship.

func NewHasMany

func NewHasMany(query contractsorm.Query, model any, association, foreignKey, localKey string) *HasMany

NewHasMany creates a new HasMany association.

func (*HasMany) Append

func (h *HasMany) Append(values ...any) error

Append appends models to the association.

func (*HasMany) Clear

func (h *HasMany) Clear() error

Clear clears the association by setting the foreign key to null for all related models.

func (*HasMany) Count

func (h *HasMany) Count() int64

Count returns the number of records in the association.

func (*HasMany) Delete

func (h *HasMany) Delete(values ...any) error

Delete removes the given values from the association.

func (*HasMany) Find

func (h *HasMany) Find(out any, conds ...any) error

Find loads the associated models for a has-many relationship.

func (*HasMany) Replace

func (h *HasMany) Replace(values ...any) error

Replace replaces the current association with the given values.

type HasOne

type HasOne struct {
	*Association
	// contains filtered or unexported fields
}

HasOne represents a has-one relationship.

func NewHasOne

func NewHasOne(query contractsorm.Query, model any, association, foreignKey, localKey string) *HasOne

NewHasOne creates a new HasOne association.

func (*HasOne) Append

func (h *HasOne) Append(values ...any) error

Append sets the foreign key to associate the model.

func (*HasOne) Clear

func (h *HasOne) Clear() error

Clear clears the association by setting the foreign key to null.

func (*HasOne) Count

func (h *HasOne) Count() int64

Count returns 1 if the association exists, 0 otherwise.

func (*HasOne) Delete

func (h *HasOne) Delete(values ...any) error

Delete removes the given value from the association.

func (*HasOne) Find

func (h *HasOne) Find(out any, conds ...any) error

Find loads the associated model for a has-one relationship.

func (*HasOne) Replace

func (h *HasOne) Replace(values ...any) error

Replace replaces the current association with the given value.

Jump to

Keyboard shortcuts

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