jsonarray

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 9 Imported by: 0

README

jsonarray

Go Reference Go Report Card Maintainability codecov

GORM JSON Array Types

Installation

go get github.com/brokeyourbike/jsonarray

Usage

package main

import (
    "github.com/brokeyourbike/jsonarray"
    "gorm.io/gorm"
)

type User struct {
    gorm.Model
    Tags jsonarray.Slice[string]
}

Authors

Thanks

License

MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Slice added in v0.2.0

type Slice[T any] []T

Slice defined JSON data type, need to implements driver.Valuer, sql.Scanner interface

func (Slice[T]) GormDBDataType added in v0.2.0

func (Slice[T]) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType gorm db data type

func (Slice[T]) GormDataType added in v0.2.0

func (m Slice[T]) GormDataType() string

GormDataType gorm common data type

func (Slice[T]) GormValue added in v0.2.0

func (m Slice[T]) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (Slice[T]) MarshalJSON added in v0.2.0

func (m Slice[T]) MarshalJSON() ([]byte, error)

MarshalJSON to output non base64 encoded []byte

func (*Slice[T]) Scan added in v0.2.0

func (m *Slice[T]) Scan(val interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*Slice[T]) UnmarshalJSON added in v0.2.0

func (m *Slice[T]) UnmarshalJSON(b []byte) error

UnmarshalJSON to deserialize []byte

func (Slice[T]) Value added in v0.2.0

func (m Slice[T]) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

Jump to

Keyboard shortcuts

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