relationship

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package relationship 用于处理多对多的数据表关系

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Relationships added in v0.13.0

type Relationships[T1, T2 T] struct {
	// contains filtered or unexported fields
}

Relationships 提供了多对多的数据表关系

func Install

func Install[T1, T2 T](mod *cmfx.Module, tableName string) *Relationships[T1, T2]

func NewRelationships added in v0.13.0

func NewRelationships[T1, T2 T](mod *cmfx.Module, tableName string) *Relationships[T1, T2]

func (*Relationships[T1, T2]) Add added in v0.13.0

func (m *Relationships[T1, T2]) Add(tx *orm.Tx, v1 T1, v2 T2) error

func (*Relationships[T1, T2]) CountByV1 added in v0.13.0

func (m *Relationships[T1, T2]) CountByV1(v1 T1) (int64, error)

func (*Relationships[T1, T2]) CountByV2 added in v0.13.0

func (m *Relationships[T1, T2]) CountByV2(v2 T2) (int64, error)

func (*Relationships[T1, T2]) Delete added in v0.13.0

func (m *Relationships[T1, T2]) Delete(tx *orm.Tx, v1 T1, v2 T2) error

func (*Relationships[T1, T2]) DeleteByV1 added in v0.13.0

func (m *Relationships[T1, T2]) DeleteByV1(tx *orm.Tx, v1 T1) error

func (*Relationships[T1, T2]) DeleteByV2 added in v0.13.0

func (m *Relationships[T1, T2]) DeleteByV2(tx *orm.Tx, v2 T2) error

func (*Relationships[T1, T2]) LeftJoin added in v0.13.0

func (m *Relationships[T1, T2]) LeftJoin(sql *sqlbuilder.SelectStmt, alias, on string)

LeftJoin LEFT JOIN 至 sql

alias 为当前的 relationshipPO 表指定别名,该别名可能在 on 参数中可能会用到;

func (*Relationships[T1, T2]) ListV1 added in v0.13.0

func (m *Relationships[T1, T2]) ListV1(v2 T2) ([]T1, error)

ListV1 列出所有与 v2 关联的 v1 列表

func (*Relationships[T1, T2]) ListV2 added in v0.13.0

func (m *Relationships[T1, T2]) ListV2(v1 T1) ([]T2, error)

ListV2 列出所有与 v1 关联的 v2 列表

type T

type T interface {
	~string | ~int | ~int64
}

T 限制了可用的字段类型

Directories

Path Synopsis
Package eav Entity-Attribute-Values 数据表管理
Package eav Entity-Attribute-Values 数据表管理

Jump to

Keyboard shortcuts

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