Merge pull request #43 from leebrooks0/master

Added a note to the docs that Gorm uses reflection to know which tables ...
This commit is contained in:
Jinzhu 2014-01-03 02:25:07 -08:00
commit 09c26cb387
1 changed files with 15 additions and 0 deletions

View File

@ -29,6 +29,19 @@ The fantastic ORM library for Golang, 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