pgjsonb

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

README

PostgreSQL jsonb type support for go

go workflow

This is a small package to support PostgreSQL jsonb data type.

Features

  1. Fully tested.
  2. Supports PostgreSQL jsonb type by sql Scanner and Valuer interfaces
  3. Supports go json Marshaller and Unmarshaller interfaces
  4. Supports go Stringer for json printing

Installation

To add the package to your project run -

go get -u github.com/asif-mahmud/pg-jsonb
Documentation

godoc: https://pkg.go.dev/github.com/asif-mahmud/pg-jsonb

Version history

Version 1.0.0

Documentation updated

Version 0.8.0

Initial version with tests for scanner and valuer interfaces.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONB

type JSONB struct {
	// contains filtered or unexported fields
}

Type to support PostgreSQL jsonb data type.

func New

func New(value any) JSONB

Creates new JSONB instance and set the underlying value to value

func (*JSONB) Get

func (j *JSONB) Get() any

Returns the underlying value. This is json decoded value scanned from sql.Row or any valid value set by the Set method.

func (JSONB) MarshalJSON

func (j JSONB) MarshalJSON() ([]byte, error)

Implements json.Marshaler interface

func (*JSONB) Scan

func (j *JSONB) Scan(value any) error

Implements sql.Scanner interface

func (*JSONB) Set

func (j *JSONB) Set(value any)

Sets underlying value, can be any valid value that can be encoded into valid json string

func (JSONB) String

func (j JSONB) String() string

Returns json encoded string for the underlying value

func (*JSONB) UnmarshalJSON

func (j *JSONB) UnmarshalJSON(data []byte) error

Implements json.Unmarshaler interface

func (JSONB) Value

func (j JSONB) Value() (driver.Value, error)

Implements sql.Valuer interface

Jump to

Keyboard shortcuts

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