associativetable

package
v0.0.0-...-5167e8f Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	Update(c *gin.Context)
	Get(c *gin.Context)
	Delete(c *gin.Context)
}

API represents associative table modification actions. Associative table API is not REST since it doesn't return error if model doesn't exist : - Update - creates model if not exist or updates model if exist - Get - returns empty model if not exist or returns model if exist - Delete - returns does nothing if not exist or deletes model if exist

func NewApi

func NewApi(
	store Store,
) API

type AssociativeTable

type AssociativeTable struct {
	Name    string  `json:"name" bson:"name" binding:"required"`
	Content Content `json:"content" bson:"content"  binding:"required"`
}

type Content

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

func (Content) MarshalBSONValue

func (c Content) MarshalBSONValue() (bsontype.Type, []byte, error)

MarshalBSONValue stores value to map because it's impossible to decode struct and array of struct to interface without bson.D and bson.D cannot be encoded to JSON properly. Try to use interface{} in mongo-driver > 1.3.7

func (Content) MarshalJSON

func (c Content) MarshalJSON() ([]byte, error)

func (*Content) UnmarshalBSONValue

func (c *Content) UnmarshalBSONValue(_ bsontype.Type, b []byte) error

func (*Content) UnmarshalJSON

func (c *Content) UnmarshalJSON(b []byte) error

type GetRequest

type GetRequest struct {
	Name string `form:"name" binding:"required"`
}

type Store

type Store interface {
	Update(ctx context.Context, model *AssociativeTable) error
	GetByName(ctx context.Context, name string) (*AssociativeTable, error)
	Delete(ctx context.Context, id string) error
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
) Store

Jump to

Keyboard shortcuts

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