parse

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Insert      = "Insert"
	Find        = "Find"
	Update      = "Update"
	Delete      = "Delete"
	Count       = "Count"
	Transaction = "Transaction"
	Bulk        = "Bulk"
)
View Source
const (
	OperateOne  = OperateMode(0)
	OperateMany = OperateMode(1)
)
View Source
const (
	One  = "One"
	Many = "Many"
)
View Source
const (
	By  = QueryMode("By")
	All = QueryMode("All")
)
View Source
const (
	And = QueryConnectionOp("And")
	Or  = QueryConnectionOp("Or")
)
View Source
const (
	Equal            = QueryComparator("Equal")
	NotEqual         = QueryComparator("NotEqual")
	LessThan         = QueryComparator("LessThan")
	LessThanEqual    = QueryComparator("LessThanEqual")
	GreaterThan      = QueryComparator("GreaterThan")
	GreaterThanEqual = QueryComparator("GreaterThanEqual")
	Between          = QueryComparator("Between")
	NotBetween       = QueryComparator("NotBetween")
	In               = QueryComparator("In")
	NotIn            = QueryComparator("NotIn")
	True             = QueryComparator("True")
	False            = QueryComparator("False")
	Exists           = QueryComparator("Exists")
	NotExists        = QueryComparator("NotExists")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkParse

type BulkParse struct {
	// Operations defines all the operations contained in the Bulk,
	// supports Insert One(Many not support), Update One Many, Delete One Many
	Operations []Operation

	// CtxParamName defines the method's context.Context param name when Bulk is called independently
	CtxParamName string

	// BelongedToMethod defines the method to which Bulk belongs
	BelongedToMethod *extract.InterfaceMethod
}

func (*BulkParse) GetOperationName

func (bp *BulkParse) GetOperationName() string

type ConnectionOpTree

type ConnectionOpTree struct {
	Name           string // if not leaf, store And || Or, else store QueryComparator(ComparatorName)
	LeftChildren   *ConnectionOpTree
	RightChildren  *ConnectionOpTree
	MongoFieldName string   // if not leaf, empty
	ParamNames     []string // if not leaf, empty
}

type CountParse

type CountParse struct {
	// Query defines the Query information contained in the Count operation
	Query *Query

	// CtxParamName defines the method's context.Context param name
	CtxParamName string

	// BelongedToMethod defines the method to which Count belongs
	BelongedToMethod *extract.InterfaceMethod
}

func (*CountParse) GetOperationName

func (cp *CountParse) GetOperationName() string

type DeleteParse

type DeleteParse struct {
	// OperateMode One or Many
	OperateMode OperateMode

	// Query defines the Query information contained in the Delete operation
	Query *Query

	// CtxParamName defines the method's context.Context param name
	CtxParamName string

	// BelongedToMethod defines the method to which Delete belongs
	BelongedToMethod *extract.InterfaceMethod
}

func (*DeleteParse) GetOperationName

func (dp *DeleteParse) GetOperationName() string

type FindParse

type FindParse struct {
	// OperateMode One or Many
	OperateMode OperateMode

	// Query defines the Query information contained in the Find operation
	Query *Query

	Project        []string
	Order          Order
	SkipParamName  string
	LimitParamName string

	// CtxParamName defines the method's context.Context param name
	CtxParamName string

	// ReturnType defines the method's first return parameter's Type which Find belongs
	ReturnType code.Type

	// BelongedToMethod defines the method to which Find belongs
	BelongedToMethod *extract.InterfaceMethod
}

func (*FindParse) GetOperationName

func (fp *FindParse) GetOperationName() string

type InsertParse

type InsertParse struct {
	// OperateMode One or Many
	OperateMode OperateMode

	// MethodParamNames defines the method's param names
	MethodParamNames [2]string

	// BelongedToMethod defines the method to which Insert belongs
	BelongedToMethod *extract.InterfaceMethod
}

func (*InsertParse) GetOperationName

func (ip *InsertParse) GetOperationName() string

type InterfaceOperation

type InterfaceOperation struct {
	BelongedToStruct *extract.IdlExtractStruct
	Operations       []Operation
}

InterfaceOperation is used to store the parsing results of the structure and for use by codegen packages.

func HandleOperations

func HandleOperations(structs []*extract.IdlExtractStruct) (result []*InterfaceOperation, err error)

type OperateMode

type OperateMode int

type Operation

type Operation interface {
	GetOperationName() string
}

type Order

type Order struct {
	Asc  []string
	Desc []string
}

type Query

type Query struct {
	// QueryMode By or All
	QueryMode QueryMode

	// ConnectionOpTree stores query information
	ConnectionOpTree *ConnectionOpTree
}

type QueryComparator

type QueryComparator string

type QueryConnectionOp

type QueryConnectionOp string

type QueryMode

type QueryMode string

type TransactionOperation

type TransactionOperation struct {
	// CollectionParamName stores the collection which the operation belongs,
	// if not specified, default is r.collection
	CollectionParamName string
	Operation           Operation
}

type TransactionParse

type TransactionParse struct {
	// TransactionOperations defines all the operations contained in the Transaction,
	// supports Insert One Many, Update One Many, Delete One Many, Bulk(Mark boundaries with parentheses).
	TransactionOperations []TransactionOperation

	// CtxParamName defines the method's context.Context param name
	CtxParamName string

	// ClientParamName defines the method's *mongo.Client param name
	ClientParamName string

	// BelongedToMethod defines the method to which Transaction belongs
	BelongedToMethod *extract.InterfaceMethod
	// contains filtered or unexported fields
}

func (*TransactionParse) GetOperationName

func (tp *TransactionParse) GetOperationName() string

type UpdateField

type UpdateField struct {
	MongoFieldName string
	ParamName      string
}

type UpdateParse

type UpdateParse struct {
	// OperateMode One or Many
	OperateMode OperateMode

	// UpdateStructObjName defines the method's structure point param name,
	// is used when updating the entire structure.
	UpdateStructObjName string

	// Query defines the Query information contained in the Update operation
	Query *Query

	// CtxParamName defines the method's context.Context param name
	CtxParamName string

	// BelongedToMethod defines the method to which Update belongs
	BelongedToMethod *extract.InterfaceMethod

	Upsert       bool
	UpdateFields []UpdateField
}

func (*UpdateParse) GetOperationName

func (up *UpdateParse) GetOperationName() string

Jump to

Keyboard shortcuts

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