sqlbuilder

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLatestJoinWithOneLevelFilter

func AddLatestJoinWithOneLevelFilter(db *gorm.DB, typeString string, tableName string, latestn int, filters []FilterCriteria) (*gorm.DB, error)

AddLatestJoinWithOneLevelFilter generates latest join with one-level filter TODO? Can tablename be part of the "?"

func AddNestedQueryJoinStmt

func AddNestedQueryJoinStmt(db *gorm.DB, typeString string, criteria TwoLevelFilterCriteria) (*gorm.DB, error)

AddNestedQueryJoinStmt adds a join statement into db

func AddWhereStmt

func AddWhereStmt(db *gorm.DB, typeString string, tableName string, filter FilterCriteria) (*gorm.DB, error)

AddWhereStmt adds where statement into db

Types

type FilterCriteria

type FilterCriteria struct {
	// TableName   string
	FieldName   string            // Field name to match
	FieldValues []string          // Criteria to match
	Predicates  []FilterPredicate // greater than less than, etc.

}

FilterCriteria is the criteria to query for first-level field

type FilterPredicate added in v0.4.9

type FilterPredicate string

FilterPredicate is the type about greater than, less than, etc

const (
	// FilterPredicateEQ is equals
	FilterPredicateEQ FilterPredicate = "="
	// FilterPredicateLT is less than
	FilterPredicateLT FilterPredicate = "<"
	// FilterPredicateLTEQ is less than or equal to
	FilterPredicateLTEQ FilterPredicate = "<="
	// FilterPredicateGT is equal to
	FilterPredicateGT FilterPredicate = ">"
	// FilterPredicateGTEQ is greater than or equal to
	FilterPredicateGTEQ FilterPredicate = ">="
)

type TwoLevelFilterCriteria

type TwoLevelFilterCriteria struct {
	OuterTableName string
	InnerTableName string
	OuterFieldName string
	Filters        []FilterCriteria // Key: inner table name,
}

TwoLevelFilterCriteria is the criteria to query for inner level field

Jump to

Keyboard shortcuts

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