dbutils

package
v0.0.0-...-2eb7c72 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FO_Open string = "open"
)

FileDbObject.Status mapping

Variables

This section is empty.

Functions

func AppendDataRow

func AppendDataRow(v any, data *[]map[string]interface{}) error

Transform a struct into json and then back into a row (array of interface{}) to insert into database using api

func DataTypeFromOID

func DataTypeFromOID(oid uint32) string

Utilities for converting postgres oid to data types see pgx/pgtype/pgtype.go https://github.com/jackc/pgx/blob/572d7fff326f1befdbf9f36a0c0a2b6661432079/pgtype/pgtype.go

func IsArrayFromOID

func IsArrayFromOID(oid uint32) bool

func IsNumeric

func IsNumeric(dtype string) bool

Types

type FileDbObject

type FileDbObject struct {
	Key           int    `json:"key"`
	WorkspaceName string `json:"workspace_name"`
	Oid           uint32 `json:"oid"`
	FileName      string `json:"file_name"`
	ContentType   string `json:"content_type"`
	Status        string `json:"status"`
	UserEmail     string `json:"user_email"`
}

func QueryFileObject

func QueryFileObject(dbpool *pgxpool.Pool, workspaceName, status, contentType string) ([]*FileDbObject, error)

Query workspace_changes table for rows by workspace_name, status, and optionally content_type (if not empty)

func (*FileDbObject) ReadObject

func (fo *FileDbObject) ReadObject(dbpool *pgxpool.Pool, fd *os.File) (int64, error)

Case fo.Oid == 0:

Expect to have fo.WorkspaceName and fo.FileName available
(alternatively could use fo.Key in future)
Returns fo with Oid, ContentType, Status, and UserEmail populated
and write the object in fd

Case fo.Oid != 0:

Write the object in fd. Does not change fo.

func (*FileDbObject) UpdateFileObject

func (fo *FileDbObject) UpdateFileObject(txWrite pgx.Tx, ctx context.Context) error

func (*FileDbObject) WriteObject

func (fo *FileDbObject) WriteObject(dbpool *pgxpool.Pool, fd *os.File) (int64, error)

Insert the content of fd into database with metadata specified by fo Expect to have fo.workspace_name and fo.file_name available Will populate fo.Oid and fo.Key

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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