eav

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package eav EAV 模式的数据库操作

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallSimple

func InstallSimple(tableName string, db *orm.DB)

InstallSimple 安装简单的 EAV 数据表

tableName 为表名;

Types

type Simple

type Simple[T any] struct {
	// contains filtered or unexported fields
}

Simple 简单的 EAV 操作接口

以 JSON 或是类似的编码保存数据,不适合查询类操作。

func NewSimple

func NewSimple[T any](tableName string, db *orm.DB, marshal serializer.MarshalFunc, unmarshal serializer.UnmarshalFunc) *Simple[T]

NewSimple 加载简要的 EAV 操作接口

tableName 为表名; marshal 和 unmarshal 表示将对象保存至表的编解码方法,如果未指定,则采用 json 的格式; T 表示存取对象的类型;

func (*Simple[T]) Delete

func (eav *Simple[T]) Delete(id int64) error

func (*Simple[T]) Insert

func (eav *Simple[T]) Insert(id int64, v *T) error

Insert 插入一条数据

id 为关联数据的 id; val 为插入的数据,其中键名为列名,键值为关联的值;

func (*Simple[T]) Select

func (eav *Simple[T]) Select(id int64, v *T) (bool, error)

func (*Simple[T]) Update

func (eav *Simple[T]) Update(id int64, v *T) error

Jump to

Keyboard shortcuts

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