mysql

package
v1.0.30 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

MYSQL

Usage

Install

import (
    _ "github.com/aacfactory/fns-contrib/databases/sql/dal/mysql"
)

SEQUENCE

create table

CREATE TABLE `sequence` (
  `name` varchar(255) NOT NULL,
  `value` bigint NOT NULL DEFAULT '0',
  `increment` int NOT NULL DEFAULT '1',
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

create function

CREATE DEFINER=`root`@`%` FUNCTION `nextval`(sname varchar(255)) RETURNS bigint
    DETERMINISTIC
BEGIN
    declare next_val bigint(20);
    declare s int;
    set next_val = 0;
    select count(`name`) into s from `sequence` where `name` = sname;
    if (s = 0) then 
        insert into `sequence` values (sname, 0, 1);
    end if;
    update `sequence` set `value` = `value` + `increment` where `name` = sname;
    select `value` into `next_val` from `sequence` where `name` = sname limit 1;
RETURN next_val;
END

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonObjectBetween

func JsonObjectBetween(column string, jsonPath string, left interface{}, right interface{}) *dal.Condition

func JsonObjectEquals

func JsonObjectEquals(column string, jsonPath string, object interface{}) *dal.Condition

func JsonObjectGT

func JsonObjectGT(column string, jsonPath string, object interface{}) *dal.Condition

func JsonObjectGTE

func JsonObjectGTE(column string, jsonPath string, object interface{}) *dal.Condition

func JsonObjectIn

func JsonObjectIn(column string, jsonPath string, arguments ...interface{}) *dal.Condition

func JsonObjectLT

func JsonObjectLT(column string, jsonPath string, object interface{}) *dal.Condition

func JsonObjectLTE

func JsonObjectLTE(column string, jsonPath string, object interface{}) *dal.Condition

func JsonObjectLeftLike

func JsonObjectLeftLike(column string, jsonPath string, value string) *dal.Condition

func JsonObjectLike

func JsonObjectLike(column string, jsonPath string, value string) *dal.Condition

func JsonObjectNotIn

func JsonObjectNotIn(column string, jsonPath string, arguments ...interface{}) *dal.Condition

func JsonObjectRightLike

func JsonObjectRightLike(column string, jsonPath string, value string) *dal.Condition

Types

type GenericQuery

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

func (*GenericQuery) WeaveDeleteWithConditions added in v1.0.6

func (generic *GenericQuery) WeaveDeleteWithConditions(ctx context.Context, cond *dal.Conditions) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*GenericQuery) WeaveExecute

func (generic *GenericQuery) WeaveExecute(_ context.Context, model dal.Model) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*GenericQuery) WeaveQuery

func (generic *GenericQuery) WeaveQuery(ctx context.Context, cond *dal.Conditions, orders *dal.Orders, rng *dal.Range) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*GenericQuery) WeaveUpdateWithValues added in v1.0.6

func (generic *GenericQuery) WeaveUpdateWithValues(ctx context.Context, values dal.Values, cond *dal.Conditions) (method dal.QueryMethod, query string, arguments []interface{}, err error)

type GenericQueryModelField

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

func (*GenericQueryModelField) Value

func (field *GenericQueryModelField) Value(modelValue reflect.Value) (v interface{})

type QueryGenerator

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

func (*QueryGenerator) Count

func (generator *QueryGenerator) Count(ctx context.Context, cond *dal.Conditions) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) Delete

func (generator *QueryGenerator) Delete(ctx context.Context, model dal.Model) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) DeleteWithConditions added in v1.0.6

func (generator *QueryGenerator) DeleteWithConditions(ctx context.Context, cond *dal.Conditions) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) Exist

func (generator *QueryGenerator) Exist(ctx context.Context, cond *dal.Conditions) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) Insert

func (generator *QueryGenerator) Insert(ctx context.Context, model dal.Model) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) InsertOrUpdate

func (generator *QueryGenerator) InsertOrUpdate(ctx context.Context, model dal.Model) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) InsertWhenExist

func (generator *QueryGenerator) InsertWhenExist(ctx context.Context, model dal.Model, source string) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) InsertWhenNotExist

func (generator *QueryGenerator) InsertWhenNotExist(ctx context.Context, model dal.Model, source string) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) Select added in v1.0.6

func (generator *QueryGenerator) Select(ctx context.Context, cond *dal.Conditions, orders *dal.Orders, rng *dal.Range) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) Update

func (generator *QueryGenerator) Update(ctx context.Context, model dal.Model) (method dal.QueryMethod, query string, arguments []interface{}, err error)

func (*QueryGenerator) UpdateWithValues added in v1.0.6

func (generator *QueryGenerator) UpdateWithValues(ctx context.Context, values dal.Values, cond *dal.Conditions) (method dal.QueryMethod, query string, arguments []interface{}, err error)

type QueryGeneratorBuilder

type QueryGeneratorBuilder struct {
}

func (*QueryGeneratorBuilder) Build

func (builder *QueryGeneratorBuilder) Build(structure *dal.ModelStructure) (generator dal.QueryGenerator, err error)

Jump to

Keyboard shortcuts

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