The fantastic ORM library for Golang, aims to be developer friendly
Go to file
Jason Lee 59408390c2 Add `db.Transaction` method for create Transaction block. (#2767)
* Add `db.Transaction` method for create Transaction block.

example:

```go
func CreateAnimals(db *gorm.DB) error {
  db.Transaction(func(tx *gorm.DB) error {
    if err := tx.Create(&Animal{Name: "Giraffe"}).Error; err != nil {
      // return any error will rollback
      return err
    }

    if err := tx.Create(&Animal{Name: "Lion"}).Error; err != nil {
      return err
    }

    // return nil will commit
    return nil
  })
}
```

* Ensure rollback when commit has error.
2019-11-19 16:08:00 +08:00
.github Simplify GitHub templates 2018-02-10 13:55:11 +08:00
dialects MSSQL Create() fix: Add LastInsertIDReturningSuffix to dialect (#2690) 2019-10-17 22:54:11 +08:00
.gitignore Enable codecov 2019-05-02 22:49:30 +08:00
License Add MIT License file 2015-01-05 08:59:18 +08:00
README.md Change gorm.io links to https 2019-05-05 16:23:52 +08:00
association.go add comment (#2163) 2018-11-03 21:55:52 +08:00
association_test.go Add tag association_autoupdate, association_autocreate, association_save_reference support 2018-02-10 17:34:02 +08:00
callback.go Log callback registration if logger exists for consistency 2019-10-25 13:51:29 -07:00
callback_create.go MSSQL Create() fix: Add LastInsertIDReturningSuffix to dialect (#2690) 2019-10-17 22:54:11 +08:00
callback_delete.go Uncapitalize error strings (#2533) 2019-09-12 22:16:52 +08:00
callback_query.go add an override on the DB instance instead of using the global NowFunc. (#2142) 2019-06-10 20:45:42 +08:00
callback_query_preload.go return empty slice for many2many if no asscociation was found 2019-03-14 02:33:42 +08:00
callback_row_query.go apply gorm:query_option in Count() 2019-04-19 14:48:52 +03:00
callback_save.go lock TagSettings structure when modified (#1796) 2018-09-10 07:11:00 +08:00
callback_system_test.go Pass logger into Callback{} so that logs are printed consistently 2019-05-07 10:42:20 -06:00
callback_update.go Uncapitalize error strings (#2533) 2019-09-12 22:16:52 +08:00
callbacks_test.go Fix CallbackProcessor.Get() for removed or replaced same name callback (#2548) 2019-09-12 22:16:05 +08:00
create_test.go add an override on the DB instance instead of using the global NowFunc. (#2142) 2019-06-10 20:45:42 +08:00
customize_column_test.go fix the table name of many2many 2019-03-14 12:35:57 +08:00
delete_test.go Fix customize DeletedAt's column name 2017-02-01 21:33:36 +08:00
dialect.go MSSQL Create() fix: Add LastInsertIDReturningSuffix to dialect (#2690) 2019-10-17 22:54:11 +08:00
dialect_common.go MSSQL Create() fix: Add LastInsertIDReturningSuffix to dialect (#2690) 2019-10-17 22:54:11 +08:00
dialect_mysql.go fix(HasTable): database name (#2717) 2019-10-21 20:45:38 +08:00
dialect_postgres.go MSSQL Create() fix: Add LastInsertIDReturningSuffix to dialect (#2690) 2019-10-17 22:54:11 +08:00
dialect_sqlite3.go lock TagSettings structure when modified (#1796) 2018-09-10 07:11:00 +08:00
docker-compose.yml Setup test env 2018-02-10 11:07:07 +08:00
embedded_struct_test.go Fix support embedded pointer type struct, close #1450 2018-02-13 10:00:18 +08:00
errors.go amended comments in error.go for clarity and grammar; for more polish when using IDEs (e.g. VSCODE) that show comments as help text (#2182) 2019-01-02 21:23:43 +08:00
errors_test.go Make gorm.Errors available for use outside gorm 2016-10-25 11:22:50 -05:00
field.go Check valuer interface before scan value (#2155) 2018-11-03 22:14:39 +08:00
field_test.go Removed the deps on uuid and appengine (#2354) 2019-04-05 07:59:02 +08:00
go.mod bump mattn/go-sqlite3 to v1.11.0 (#2565) 2019-09-12 22:13:59 +08:00
go.sum bump mattn/go-sqlite3 to v1.11.0 (#2565) 2019-09-12 22:13:59 +08:00
interface.go Add BeginTx for parity with sql.DB.BeginTx (#2227) 2019-06-10 20:33:20 +08:00
join_table_handler.go Call DefaultTableNameHandler for JoinTableHandler's table 2018-02-12 09:43:28 +08:00
join_table_test.go mysql only accept offset with limit together 2017-07-03 11:26:31 +08:00
logger.go fix insert timezero 0001-01-01 (#2635) 2019-09-02 09:44:50 +08:00
main.go Add `db.Transaction` method for create Transaction block. (#2767) 2019-11-19 16:08:00 +08:00
main_test.go Add `db.Transaction` method for create Transaction block. (#2767) 2019-11-19 16:08:00 +08:00
migration_test.go Handle syntax to specify an index prefix length 2019-04-20 01:04:23 +09:00
model.go Rename test files 2016-03-08 22:00:15 +08:00
model_struct.go fix a race condition on IsForeignKey that is being detected by -race sometimes. 2019-10-22 11:35:11 +02:00
model_struct_test.go fix a race condition on IsForeignKey that is being detected by -race sometimes. 2019-10-22 11:35:11 +02:00
multi_primary_keys_test.go Fix tests with mssql 2017-03-22 23:50:42 +08:00
naming.go added naming strategy option for db, table and column names (#2040) 2018-09-10 05:52:20 +08:00
naming_test.go added naming strategy option for db, table and column names (#2040) 2018-09-10 05:52:20 +08:00
pointer_test.go Fix some go vet/lint reports 2016-01-15 21:16:48 +08:00
polymorphic_test.go Refactor named value support for PolymorphicType 2016-10-06 20:33:48 +08:00
preload_test.go gofmt 2019-04-14 12:30:11 +04:00
query_test.go Revert "Fix #2517 : Check for incomplete parentheses to prevent SQL injection." (#2674) 2019-09-25 19:22:43 +08:00
scaner_test.go Fix tests with mssql 2017-03-22 23:50:42 +08:00
scope.go Rename expr type to make it public. (#2604) 2019-10-17 23:44:34 +08:00
scope_test.go Fix drop table error with table options 2019-05-08 10:23:31 +04:00
search.go Rename expr type to make it public. (#2604) 2019-10-17 23:44:34 +08:00
search_test.go Add SelectAttrs, OmitAttrs 2015-03-12 15:50:38 +08:00
test_all.sh Set AutoIncrement to false with tag 2018-02-10 08:24:39 +08:00
update_test.go Fixing 4 typos in comments and gofmt -s in all files 2017-02-10 16:16:38 -02:00
utils.go Rename expr type to make it public. (#2604) 2019-10-17 23:44:34 +08:00
wercker.yml Update wercker.yml to include mysql 8 2019-06-13 11:48:31 +08:00

README.md

GORM

The fantastic ORM library for Golang, aims to be developer friendly.

go report card wercker status codecov Join the chat at https://gitter.im/jinzhu/gorm Open Collective Backer Open Collective Sponsor MIT license GoDoc

Overview

  • Full-Featured ORM (almost)
  • Associations (Has One, Has Many, Belongs To, Many To Many, Polymorphism)
  • Hooks (Before/After Create/Save/Update/Delete/Find)
  • Preloading (eager loading)
  • Transactions
  • Composite Primary Key
  • SQL Builder
  • Auto Migrations
  • Logger
  • Extendable, write Plugins based on GORM callbacks
  • Every feature comes with tests
  • Developer Friendly

Getting Started

Contributing

You can help to deliver a better GORM, check out things you can do

License

© Jinzhu, 2013~time.Now

Released under the MIT License