eav

package
v0.7.13 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package eav EAV 模式的数据库操作

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallSimple

func InstallSimple(mod *cmfx.Module, tableName string)

InstallSimple 安装简单的 EAV 数据表

tableName 为表名;

Types

type MarshalFunc

type MarshalFunc func(any) ([]byte, error)

type Simple

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

Simple 简单的 EAV 操作接口

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

func NewSimple

func NewSimple[T any](mod *cmfx.Module, tableName string, marshal MarshalFunc, unmarshal UnmarshalFunc) *Simple[T]

NewSimple 声明 Simple 对象

mod 表示所属的模块; 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

type UnmarshalFunc

type UnmarshalFunc func([]byte, any) error

Jump to

Keyboard shortcuts

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