ssorm

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 13 Imported by: 0

README

SSORM

SSORM is a simple spanner orm

Overview

  • Feature
    • Insert (Model)
    • Update (Model and Columns and Params)
    • Find (Model)
    • First (Model)
    • Count (Model)
    • Delete (Model and Where)
    • SubQuery (Model)
    • SoftDelete (Insert Update Find First Count Delete SubQuery)

Test

  • Config spanner-emulator && create instance && create database && insert record

    . ./tests/ddl/create_datbase.sh
    
  • Run test

    go test -v ./tests/...
    

Custom Logger

ssorm.Logger({custom logger})

Logger Interface

type ILogger interface {
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
Panicf(format string, args ...interface{})
}

License

Copyright (c) 2021 10ANTZ, Inc.

Released under the MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

type DB

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

func Model

func Model(model interface{}, opts ...Option) *DB

func SoftDeleteModel

func SoftDeleteModel(model interface{}, opts ...Option) *DB

func (*DB) AddSub

func (db *DB) AddSub(model interface{}, query interface{}, values ...interface{}) *DB

func (*DB) Count

func (db *DB) Count(ctx context.Context, spannerTransaction interface{}, cnt interface{}) error

func (*DB) DeleteModel

func (db *DB) DeleteModel(ctx context.Context, spannerTransaction *spanner.ReadWriteTransaction) (int64, error)

func (*DB) DeleteWhere

func (db *DB) DeleteWhere(ctx context.Context, spannerTransaction *spanner.ReadWriteTransaction) (int64, error)

func (*DB) Find

func (db *DB) Find(ctx context.Context, spannerTransaction interface{}) error

func (*DB) First

func (db *DB) First(ctx context.Context, spannerTransaction interface{}) error

func (*DB) Insert

func (db *DB) Insert(ctx context.Context, spannerTransaction *spanner.ReadWriteTransaction) (int64, error)

func (*DB) Limit

func (db *DB) Limit(limit int64) *DB

func (*DB) Offset

func (db *DB) Offset(offset int64) *DB

func (*DB) Order

func (db *DB) Order(order string) *DB

func (*DB) Select

func (db *DB) Select(query []string) *DB

func (*DB) TableName

func (db *DB) TableName(tableName string) *DB

func (*DB) Update

func (db *DB) Update(ctx context.Context, spannerTransaction *spanner.ReadWriteTransaction) (int64, error)

func (*DB) UpdateColumns

func (db *DB) UpdateColumns(ctx context.Context, spannerTransaction *spanner.ReadWriteTransaction, in []string) (int64, error)

func (*DB) UpdateParams

func (db *DB) UpdateParams(ctx context.Context, spannerTransaction *spanner.ReadWriteTransaction, in map[string]interface{}) (int64, error)

func (*DB) Where

func (db *DB) Where(query interface{}, values ...interface{}) *DB

type ILogger

type ILogger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})
}

func NewLogger

func NewLogger(out io.Writer) ILogger

type Option

type Option func(*DB)

func Logger

func Logger(l ILogger) Option

type SubBuilder

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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