Model is core struct implementing the DAO for ORM.
| 17 | |
| 18 | // Model is core struct implementing the DAO for ORM. |
| 19 | type Model struct { |
| 20 | db DB // Underlying DB interface. |
| 21 | tx TX // Underlying TX interface. |
| 22 | rawSql string // rawSql is the raw SQL string which marks a raw SQL based Model not a table based Model. |
| 23 | schema string // Custom database schema. |
| 24 | linkType int // Mark for operation on master or slave. |
| 25 | tablesInit string // Table names when model initialization. |
| 26 | tables string // Operation table names, which can be more than one table names and aliases, like: "user", "user u", "user u, user_detail ud". |
| 27 | fields []any // Operation fields, multiple fields joined using char ','. |
| 28 | fieldsEx []any // Excluded operation fields, it here uses slice instead of string type for quick filtering. |
| 29 | withArray []any // Arguments for With feature. |
| 30 | withAll bool // Enable model association operations on all objects that have "with" tag in the struct. |
| 31 | extraArgs []any // Extra custom arguments for sql, which are prepended to the arguments before sql committed to underlying driver. |
| 32 | whereBuilder *WhereBuilder // Condition builder for where operation. |
| 33 | groupBy string // Used for "group by" statement. |
| 34 | orderBy string // Used for "order by" statement. |
| 35 | having []any // Used for "having..." statement. |
| 36 | start int // Used for "select ... start, limit ..." statement. |
| 37 | limit int // Used for "select ... start, limit ..." statement. |
| 38 | option int // Option for extra operation features. |
| 39 | offset int // Offset statement for some databases grammar. |
| 40 | partition string // Partition table partition name. |
| 41 | data any // Data for operation, which can be type of map/[]map/struct/*struct/string, etc. |
| 42 | batch int // Batch number for batch Insert/Replace/Save operations. |
| 43 | filter bool // Filter data and where key-value pairs according to the fields of the table. |
| 44 | distinct string // Force the query to only return distinct results. |
| 45 | lockInfo string // Lock for update or in shared lock. |
| 46 | cacheEnabled bool // Enable sql result cache feature, which is mainly for indicating cache duration(especially 0) usage. |
| 47 | cacheOption CacheOption // Cache option for query statement. |
| 48 | pageCacheOption []CacheOption // Cache option for paging query statement. |
| 49 | hookHandler HookHandler // Hook functions for model hook feature. |
| 50 | unscoped bool // Disables soft deleting features when select/delete operations. |
| 51 | safe bool // If true, it clones and returns a new model object whenever operation done; or else it changes the attribute of current model. |
| 52 | onDuplicate any // onDuplicate is used for on Upsert clause. |
| 53 | onDuplicateEx any // onDuplicateEx is used for excluding some columns on Upsert clause. |
| 54 | onConflict any // onConflict is used for conflict keys on Upsert clause. |
| 55 | tableAliasMap map[string]string // Table alias to true table name, usually used in join statements. |
| 56 | softTimeOption SoftTimeOption // SoftTimeOption is the option to customize soft time feature for Model. |
| 57 | shardingConfig ShardingConfig // ShardingConfig for database/table sharding feature. |
| 58 | shardingValue any // Sharding value for sharding feature. |
| 59 | } |
| 60 | |
| 61 | // ModelHandler is a function that handles given Model and returns a new Model that is custom modified. |
| 62 | type ModelHandler func(m *Model) *Model |
nothing calls this directly
no outgoing calls
no test coverage detected