rdbms

package
v0.0.0-...-7a3883e Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCachingDurationSeconds  = 300
	MaxArrayCachingDurationSeconds = 180
)

Constants

View Source
const (
	DefaultDatasourceName = "default"
	DefaultSqliteFile     = "../data/default.db"
	DefaultDatabaseName   = "default"

	PingTimeoutSeconds = 5
)

Constants

Variables

View Source
var (
	ErrNoPrimaryKeyFields    = errors.New("No primary key filed defined")
	ErrEmptyPrimaryKeyFields = errors.New("No primary key field were set")
)

Variables

Functions

func ExecuteGraphQLQuery

func ExecuteGraphQLQuery(query string, schema *graphql.Schema) *graphql.Result

ExecuteGraphQLQuery execute GraphQL query

func GetSQLParamPlaceholderString

func GetSQLParamPlaceholderString(driverName string) string

GetSQLParamPlaceholderString get sql parameter placeholder

func GetSQLQuoteString

func GetSQLQuoteString(driverName string) string

GetSQLQuoteString get sql quote

func NewGraphQLMutationSchema

func NewGraphQLMutationSchema(beanValue reflect.Value, beanGraphQLSchemaInfo *BeanGraphQLSchemaInfo) *graphql.Object

NewGraphQLMutationSchema new mutation type

func NewGraphQLQuerySchema

func NewGraphQLQuerySchema(beanValue reflect.Value, beanGraphQLSchemaInfo *BeanGraphQLSchemaInfo) *graphql.Object

NewGraphQLQuerySchema new query type

func NewGraphQLSchema

func NewGraphQLSchema(beanValue reflect.Value, beanGraphQLSchemaInfo *BeanGraphQLSchemaInfo) *graphql.Schema

NewGraphQLSchema new schema

func RegisterGraphQLMQs

func RegisterGraphQLMQs(mqConfigCategory string, responseMQConfigCategory string, beans []interface{}) error

RegisterGraphQLMQs register models as graphql mq api

func RegisterGraphQLRoutes

func RegisterGraphQLRoutes(app router.Party, beans []interface{}) error

RegisterGraphQLRoutes register models as graphql api

Types

type BeanGraphQLSchemaInfo

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

BeanGraphQLSchemaInfo graphql info

func (*BeanGraphQLSchemaInfo) GenerateConditionBean

func (i *BeanGraphQLSchemaInfo) GenerateConditionBean(args map[string]interface{}) (interface{}, bool)

GenerateConditionBean generate contidion bean

func (*BeanGraphQLSchemaInfo) GenerateGraphQLArgs

func (i *BeanGraphQLSchemaInfo) GenerateGraphQLArgs() graphql.FieldConfigArgument

GenerateGraphQLArgs generate arguments for graphql

func (*BeanGraphQLSchemaInfo) GetSchema

func (i *BeanGraphQLSchemaInfo) GetSchema() *graphql.Schema

GetSchema get schema

func (*BeanGraphQLSchemaInfo) HandlerQuery

func (i *BeanGraphQLSchemaInfo) HandlerQuery(ctx iris.Context)

HandlerQuery handle GraphQL query

func (*BeanGraphQLSchemaInfo) Name

func (i *BeanGraphQLSchemaInfo) Name() string

Name name of schema

type DataAccessEngine

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

DataAccessEngine data access layer manager

func GetInstance

func GetInstance() *DataAccessEngine

GetInstance data persistence manager

func (*DataAccessEngine) Count

func (dae *DataAccessEngine) Count(bean interface{}, customConds ...map[string]interface{}) (int64, error)

Count record counts from table, bean's non-empty fields are conditions.

func (*DataAccessEngine) Delete

func (dae *DataAccessEngine) Delete(bean interface{}) (int64, error)

Delete record from table, bean's non-empty fields are conditions.

func (*DataAccessEngine) EnableAutoSyncTableStructure

func (dae *DataAccessEngine) EnableAutoSyncTableStructure(enabled bool)

EnableAutoSyncTableStructure set if enables auto syncronize the table structure with database if enabled, table structure would be auto syncronized to database once first call orm model operation

func (*DataAccessEngine) EnableAutoTime

func (dae *DataAccessEngine) EnableAutoTime(enabled bool)

EnableAutoTime enable auto time for created, updated event if enabled, the model BeforeInsert and BeforeUpdate event would not be effective for saving to db

func (*DataAccessEngine) EnsureTableStructures

func (dae *DataAccessEngine) EnsureTableStructures(beanOrTableName interface{}) error

EnsureTableStructures check if the table named in {beanOrTableName} struct exists in database, create it if not exixts.

func (*DataAccessEngine) Exists

func (dae *DataAccessEngine) Exists(bean interface{}, customConds ...map[string]interface{}) (bool, error)

Exists check record exists from table, bean's non-empty fields are conditions. The bean should be a pointer to a struct

func (*DataAccessEngine) FetchAll

func (dae *DataAccessEngine) FetchAll(condiBeans interface{}, customConds ...map[string]interface{}) ([]interface{}, error)

FetchAll fetch all data object from database on conditionBean Nodes: there would be a max {MaxArrayCachingDurationSeconds} seconds non-syncronized to db data in case inserted some records in rows that conditionBean specifies.

func (*DataAccessEngine) FetchOne

func (dae *DataAccessEngine) FetchOne(bean interface{}, customConds ...map[string]interface{}) (bool, error)

FetchOne Get retrieve one record from table, bean's non-empty fields are conditions. The bean should be a pointer to a struct

func (*DataAccessEngine) FetchRecords

func (dae *DataAccessEngine) FetchRecords(condiBeans interface{}, limit, offset int, customConds ...map[string]interface{}) ([]interface{}, error)

FetchRecords fetch all data object from database on conditionBean and limit, offset Nodes: there would be a max {MaxArrayCachingDurationSeconds} seconds non-syncronized to db data in case inserted some records in rows that conditionBean specifies. while, this case would not be commonly comes out because that the new record would be inserted at the tail of rows in many databases

func (*DataAccessEngine) FetchRecordsAndCountTotal

func (dae *DataAccessEngine) FetchRecordsAndCountTotal(condiBeans interface{}, limit, offset int, results interface{}, customConds ...map[string]interface{}) (int64, error)

FetchRecordsAndCountTotal fetch all data object from database on conditionBean and limit, offset Nodes: there would be a max {MaxArrayCachingDurationSeconds} seconds non-syncronized to db data in case inserted some records in rows that conditionBean specifies. while, this case would not be commonly comes out because that the new record would be inserted at the tail of rows in many databases returns total count of records in database by condiBeans and error object if gots error

func (*DataAccessEngine) GetDbEngine

func (dae *DataAccessEngine) GetDbEngine(beanOrTableName interface{}) (*xorm.Engine, error)

GetDbEngine get table datasource name

func (*DataAccessEngine) Init

func (dae *DataAccessEngine) Init(dbDatasourceName string, dbConfig *definations.DBConnectorConfig) (*xorm.Engine, error)

Init db instance with config

func (*DataAccessEngine) Insert

func (dae *DataAccessEngine) Insert(beans ...interface{}) (int64, error)

Insert save record data to table, bean's ID field would be primary key conditions.

func (*DataAccessEngine) InsertMulti

func (dae *DataAccessEngine) InsertMulti(beans []interface{}) (int64, error)

InsertMulti insert records data to table, bean's ID field would be primary key conditions.

func (*DataAccessEngine) IsValid

func (dae *DataAccessEngine) IsValid() bool

IsValid is any engine valid

func (*DataAccessEngine) Ping

func (dae *DataAccessEngine) Ping() error

Ping all engines

func (*DataAccessEngine) QueryRelationData

func (dae *DataAccessEngine) QueryRelationData(relationQuery RelationQuery, structRowParameterField string, structRowRelationsField string, structRows interface{}) ([]map[string]interface{}, error)

QueryRelationData query the table relation data

func (*DataAccessEngine) QueryRelationsAsMappedInterface

func (dae *DataAccessEngine) QueryRelationsAsMappedInterface(relationQuery RelationQuery, args ...interface{}) ([]map[string]interface{}, error)

QueryRelationsAsMappedInterface query the relationship mapper includes data

func (*DataAccessEngine) SaveOne

func (dae *DataAccessEngine) SaveOne(bean interface{}) (bool, error)

SaveOne save record data to table, bean's ID field would be primary key conditions.

func (*DataAccessEngine) StartKeepAlive

func (dae *DataAccessEngine) StartKeepAlive()

StartKeepAlive keepalive

func (*DataAccessEngine) Table

func (dae *DataAccessEngine) Table(beanOrTableName interface{}) (*xorm.Session, error)

Table sepcify table session of db engine

type Datasource

type Datasource struct {
}

Datasource an struct that specifies datasource name the database schema model should be like this: ```

type SchemaDemo struct {
    Name string      `xorm:"'name' VARCHAR(50) default('')"`
    rdbms.Datasource `xorm:"'-' datasource:"demo"`
}

```

func (*Datasource) Count

func (s *Datasource) Count(bean interface{}) (int64, error)

Count record

func (*Datasource) Delete

func (s *Datasource) Delete(bean interface{}) (int64, error)

Delete record

func (*Datasource) Exists

func (s *Datasource) Exists(bean interface{}) (bool, error)

Exists by record

func (*Datasource) Fetch

func (s *Datasource) Fetch(bean interface{}) (bool, error)

Fetch retrieve record data from table, bean's non-empty fields are conditions

func (*Datasource) Insert

func (s *Datasource) Insert(beans ...interface{}) (int64, error)

Insert record data to table

func (*Datasource) InsertMulti

func (s *Datasource) InsertMulti(beans []interface{}) (int64, error)

InsertMulti records data to table

func (*Datasource) Save

func (s *Datasource) Save(bean interface{}) (bool, error)

Save record data to table

type GraphQLDelegate

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

GraphQLDelegate GraphQL operator wrapper

func GraphQL

func GraphQL() *GraphQLDelegate

GraphQL delegate

func (*GraphQLDelegate) GetGraphQLSchemaInfo

func (g *GraphQLDelegate) GetGraphQLSchemaInfo(bean interface{}) *BeanGraphQLSchemaInfo

GetGraphQLSchemaInfo of xorm bean

type IDatasource

type IDatasource interface {
	Datasource() string
}

IDatasource interface

type IDatasourceName

type IDatasourceName interface {
	DatasourceName() string
}

IDatasourceName interface

type IGetDatasource

type IGetDatasource interface {
	GetDatasource() string
}

IGetDatasource interface

type RelationQuery

type RelationQuery struct {
	Select              string
	RelationTable       names.TableName
	TargetTable         names.TableName
	SelfRelationField   string
	TargetRelationField string
	TargetPrimaryKey    string
}

RelationQuery for relation includes query examples: tables: user(id) - user_role_map(user_id, role_id) - role(id)

RelationTable is user_role_map
TargetTable is role
SelfRelationField is user_id
TargetRelationField is role_id
TargetPrimaryKey is (role.)id

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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