Skip to main content
Version: 2.8.x(Latest)

Introduction

gdb chaining operation is simple and flexible, and is the officially recommended database operation method by the GoFrame framework. Chaining operation can be done by using the db.Model method of the database object or the tx.Model method of the transaction object, which returns a chaining operation object *Model based on the specified data table. This object can perform the following methods. The current method list may lag behind the source code; for a detailed method list, please refer to the API documentation: https://pkg.go.dev/github.com/gogf/gf/v2/database/gdb#Model

Partially Unsupported Operations

Below is the support status of the latest version

TypeReplaceSaveInsertIgnoreInsertGetIdLastInsertIdTransactionRowsAffected
mysqlSupportedSupportedSupportedSupportedSupportedSupportedSupported
mariadbSupportedSupportedSupportedSupportedSupportedSupportedSupported
tidbSupportedSupportedSupportedSupportedSupportedSupportedSupported
pgsqlUnsupportedSupportedUnsupportedSupportedSupportedSupportedSupported
mssqlUnsupportedSupportedSupportedSupportedUnsupportedSupportedSupported
sqliteUnsupportedSupportedSupportedSupportedSupportedSupportedSupported
oracleUnsupportedSupportedSupportedSupportedUnsupportedSupportedSupported
dmUnsupportedSupportedSupportedSupportedSupportedSupportedSupported
clickhouseUnsupportedUnsupportedUnsupportedUnsupportedSupportedUnsupportedUnsupported

Documents

📄️ ORM Model - Update/Delete

Performing ORM chaining operations for data update and delete in the GoFrame framework. Emphasizes the importance of using the Update and Delete methods with Where conditions. Additionally, explores the feature of using Counter parameters to increase or decrease field values, and using the Increment and Decrement methods for field operations. It also explains techniques for embedding native SQL statements and implementing soft delete to ensure flexibility and security in data processing.

📄️ ORM Model - Master/Slave

Implement master-slave configuration and read-write separation at the application layer using gdb in the GoFrame framework. With simple configuration, gdb can automatically switch between master and slave, significantly improving database performance and availability. This article also provides examples of using Master and Slave methods for custom node operations, helping developers better address issues related to master-slave synchronization delay and ensure data timeliness and accuracy.

📄️ ORM Model - Query Cache

Performing query cache operations using the ORM in the GoFrame framework. It supports caching to optimize query results, suitable for scenarios with more reads and fewer writes. The article provides a detailed introduction to cache management and adaptation, especially how to implement distributed caching using Redis. It also provides sample code showing table structures and their caching effects, demonstrating query cache implementation and cache clearing functions.

📄️ ORM Model - Lock

How to implement pessimistic and optimistic locks through chaining operations in the GoFrame framework. Pessimistic locks are used to lock data during each access to prevent conflicts, commonly in high concurrency scenarios; while optimistic locks use a versioning mechanism to check data updates, suitable for scenarios with more reads and fewer writes. This document provides a detailed analysis of applicable scenarios, implementation methods, and the advantages and disadvantages of locking mechanisms to help developers optimize database performance.