go_pg_protobuf_types

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 5 Imported by: 0

README

Protobuf types for go-pg

Example


// Connect to the PostgreSQL
db := pg.Connect(&pg.Options{
	User: "postgres",
})

// Register protobuf appender and scanner
go_pg_protobuf_types.RegisterAppenderAndScanner()

ctx := context.Background()

if err := db.Ping(ctx); err != nil {
    panic(err)
}

// Example struct
type MySchema struct {
    tableName struct{} `pg:"your_table"`

    IsLocked *wrapperspb.BoolValue `protobuf:"bytes,1,opt,name=is_locked,json=isLocked,proto3" json:"is_locked,omitempty"`
    CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" pg:",type:timestamptz"`
}

// Select query
var schema []*MySchema
err := db.Model(&schema).Select()
if err != nil {
	panic(err)
}

// Result
fmt.Printf("%v", schema)

// outputs: 
// [is_locked:{value:true} create_time:{seconds:1667842124 nanos:909462000}]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolValueAppender

func BoolValueAppender(in []byte, v reflect.Value, flags int) []byte

func BoolValueScanner

func BoolValueScanner(v reflect.Value, rd types.Reader, n int) error

func BytesValueAppender

func BytesValueAppender(in []byte, v reflect.Value, flags int) []byte

func BytesValueScanner

func BytesValueScanner(v reflect.Value, rd types.Reader, n int) error

func DoubleValueAppender

func DoubleValueAppender(in []byte, v reflect.Value, flags int) []byte

func DoubleValueScanner

func DoubleValueScanner(v reflect.Value, rd types.Reader, n int) error

func FloatValueAppender

func FloatValueAppender(in []byte, v reflect.Value, flags int) []byte

func FloatValueScanner

func FloatValueScanner(v reflect.Value, rd types.Reader, n int) error

func Int32ValueAppender

func Int32ValueAppender(in []byte, v reflect.Value, flags int) []byte

func Int32ValueScanner

func Int32ValueScanner(v reflect.Value, rd types.Reader, n int) error

func Int64ValueAppender

func Int64ValueAppender(in []byte, v reflect.Value, flags int) []byte

func Int64ValueScanner

func Int64ValueScanner(v reflect.Value, rd types.Reader, n int) error

func RegisterAppenderAndScanner

func RegisterAppenderAndScanner()

func StringValueAppender

func StringValueAppender(in []byte, v reflect.Value, flags int) []byte

func StringValueScanner

func StringValueScanner(v reflect.Value, rd types.Reader, n int) error

func TimestampAppender

func TimestampAppender(in []byte, v reflect.Value, flags int) []byte

func TimestampScanner

func TimestampScanner(v reflect.Value, rd types.Reader, n int) error

func UInt32ValueAppender

func UInt32ValueAppender(in []byte, v reflect.Value, flags int) []byte

func UInt32ValueScanner

func UInt32ValueScanner(v reflect.Value, rd types.Reader, n int) error

func UInt64ValueAppender

func UInt64ValueAppender(in []byte, v reflect.Value, flags int) []byte

func UInt64ValueScanner

func UInt64ValueScanner(v reflect.Value, rd types.Reader, n int) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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