Added a note to the docs that Gorm uses reflection to know which tables to work with

This commit is contained in:
Lee Brooks 2014-01-03 11:26:50 +02:00
parent a2e26d3641
commit 37abd81de2
1 changed files with 15 additions and 0 deletions

View File

@ -29,6 +29,19 @@ Yet Another ORM library for Go, aims to be developer friendly.
* Use `CreatedAt` to store record's created time if field exists. * Use `CreatedAt` to store record's created time if field exists.
* Use `UpdatedAt` to store record's updated time if field exists. * Use `UpdatedAt` to store record's updated time if field exists.
* Use `DeletedAt` to store record's deleted time if field exists. [Soft Delete](#soft-delete) * Use `DeletedAt` to store record's deleted time if field exists. [Soft Delete](#soft-delete)
* Gorm uses reflection to know which tables to work with:
```go
// E.g Finding an existing User
var user User
// Gorm will now know to use table "users" ("user" if pluralisation has been disabled) for all operations.
db.First(&user)
// E.g creating a new User
DB.Save(&User{Name: "xxx"}) // table "users"
```
# Getting Started
```go ```go
import ( import (
@ -163,6 +176,8 @@ If the table doesn't exist when AutoMigrate, gorm will run create the table auto
db.AutoMigrate(User{}) db.AutoMigrate(User{})
``` ```
# Gorm API
## Create ## Create
```go ```go