git-statszgo.at/git-stats/db2 Index | Files

package db2

import "zgo.at/git-stats/db2"

Index

Functions

func AddTable

func AddTable(t any, tbl string)

func Insert

func Insert(ctx context.Context, t any, extraSQL ...string) error

Insert all struct fields of t in the table tbl.

Column names are taken from the db tag. Fields with the db tag set to "-" or that have the ",noinsert" option will be skipped.

If a field has the ",id" option it will be set.

func Update

func Update(ctx context.Context, old, new any) (map[string][2]any, error)

Update all fields that are changed between old and new.

No SQL is run if old and new are identical.

Returns a map of changes, as [2]any{oldValue, newValue}.

Source Files

db2.go

Version
v0.0.0-20240410145522-3037a55246c2 (latest)
Published
Apr 10, 2024
Platform
linux/amd64
Imports
9 packages
Last checked
1 month ago

Tools for package owners.