reorm

package module
v0.0.0-...-ab0fe71 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: MIT Imports: 5 Imported by: 0

README

re-orm

Go Report Card codebeat badge Build Status

Implementation of ORM for Redis

Its supports mapping of the sturcts, find by the struct attributes, etc TODO

See https://github.com/saromanov/re-orm/tree/master/examples of usage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address    string
	Password   string
	Serializer serializer.Serializer
	// KeyPrefix returns prefix where data will be saved
	// for example "prefix_id"
	KeyPrefix string
	SetType   SetType
}

Config defines configuration for the project

type ReOrm

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

ReOrm provides implementation of the Redis ORM

func New

func New(c *Config) (*ReOrm, error)

New initialize Redis Orm

func (*ReOrm) DeleteByID

func (r *ReOrm) DeleteByID(req interface{}, ID interface{}) error

DeleteByID provides removing of the data by id

func (*ReOrm) Find

func (r *ReOrm) Find(req interface{}) ([]interface{}, error)

Find provides finding of the data by non-default values at the req. For example: r.Find(&Car{Name: "BMW"}) And it should find by the field "Name"

func (*ReOrm) Get

func (r *ReOrm) Get(resp, data interface{}) error

Get provides getting of the data by search request

func (*ReOrm) GetByID

func (r *ReOrm) GetByID(name string, ID, data interface{}) error

GetByID provides getting of the data by id

func (*ReOrm) GetValueByField

func (r *ReOrm) GetValueByField(name, field string, req interface{}) (interface{}, error)

GetValueByField provides getting of the data by the field from the struct

func (*ReOrm) Last

func (r *ReOrm) Last(resp, data interface{}) error

Last provides getting of the last element if data is duplicated

func (*ReOrm) Save

func (r *ReOrm) Save(data ...interface{}) error

Save provides saving of the data. Also, it returns stored id

func (*ReOrm) Update

func (r *ReOrm) Update(id, req interface{}) error

Update provides updating of the data by request

type SetType

type SetType int

SetType defines type for the set for index insering

var (
	// ZADD provides definition of the type for inserting
	ZADD SetType = 0
	// SADD provides definition of the type for inserting
	SADD SetType = 1
)

Directories

Path Synopsis
internal
config
Package config defines inner representation of the config
Package config defines inner representation of the config
unique
Package unique defines generation of id's for data
Package unique defines generation of id's for data

Jump to

Keyboard shortcuts

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