From 37abd81de22078cdb19e29813a128b42a0608698 Mon Sep 17 00:00:00 2001 From: Lee Brooks Date: Fri, 3 Jan 2014 11:26:50 +0200 Subject: [PATCH] Added a note to the docs that Gorm uses reflection to know which tables to work with --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 3060c908..157e57b3 100644 --- a/README.md +++ b/README.md @@ -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 `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) +* 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 import ( @@ -163,6 +176,8 @@ If the table doesn't exist when AutoMigrate, gorm will run create the table auto db.AutoMigrate(User{}) ``` +# Gorm API + ## Create ```go