Skip to content

Latest commit

 

History

History
42 lines (25 loc) · 1.11 KB

quirrel.md

File metadata and controls

42 lines (25 loc) · 1.11 KB

Table of Contents generated with DocToc

Masterminds/squirrel

比ORM还是要复杂一些,却又比裸写SQL好一些(可维护性好一些,不容易出 SQL注入问题)

源码分析

squirrel的四大结构体

  • SelectBuilder
  • UpdateBuilder
  • InsertBuilder
  • DeleteBuilde

这里拿 Select 进行说明

// github.com/!masterminds/[email protected]/statement.go

// StatementBuilderType is the type of StatementBuilder.
type StatementBuilderType builder.Builder

// StatementBuilder is a parent builder for other builders, e.g. SelectBuilder.
var StatementBuilder = StatementBuilderType(builder.EmptyBuilder).PlaceholderFormat(Question)

func Select(columns ...string) SelectBuilder {
	return StatementBuilder.Select(columns...)
}