Build documents

This commit is contained in:
Jinzhu 2018-02-09 08:14:51 +08:00
parent 792b9b3547
commit 9c76bdaf49
13 changed files with 1231 additions and 69 deletions

View File

@ -7,7 +7,7 @@
<title>Advanced Usage · GORM Guide</title> <title>Advanced Usage · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content=""> <meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2"> <meta name="generator" content="GitBook 3.2.3">
@ -602,12 +602,48 @@
</li> </li>
<li class="chapter " data-level="1.8" data-path="changelog.html"> <li class="chapter " data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.9" data-path="changelog.html">
<a href="changelog.html"> <a href="changelog.html">
<b>1.8.</b> <b>1.9.</b>
Change Log Change Log
@ -836,7 +872,7 @@ db.SetLogger(log.New(os.Stdout, <span class="hljs-string">&quot;\r\n&quot;</span
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Advanced Usage","level":"1.6","depth":1,"next":{"title":"Error Handling","level":"1.6.1","depth":2,"anchor":"#error-handling","path":"advanced.md","ref":"advanced.md#error-handling","articles":[]},"previous":{"title":"Callbacks","level":"1.5","depth":1,"path":"callbacks.md","ref":"callbacks.md","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"advanced.md","mtime":"2017-10-18T10:40:29.845Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-10-18T10:41:23.502Z"},"basePath":".","book":{"language":""}}); gitbook.page.hasChanged({"page":{"title":"Advanced Usage","level":"1.6","depth":1,"next":{"title":"Error Handling","level":"1.6.1","depth":2,"anchor":"#error-handling","path":"advanced.md","ref":"advanced.md#error-handling","articles":[]},"previous":{"title":"Callbacks","level":"1.5","depth":1,"path":"callbacks.md","ref":"callbacks.md","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"advanced.md","mtime":"2018-02-09T00:11:55.540Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
}); });
</script> </script>
</div> </div>

View File

@ -7,7 +7,7 @@
<title>Associations · GORM Guide</title> <title>Associations · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content=""> <meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2"> <meta name="generator" content="GitBook 3.2.3">
@ -602,12 +602,48 @@
</li> </li>
<li class="chapter " data-level="1.8" data-path="changelog.html"> <li class="chapter " data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.9" data-path="changelog.html">
<a href="changelog.html"> <a href="changelog.html">
<b>1.8.</b> <b>1.9.</b>
Change Log Change Log
@ -932,7 +968,7 @@ db.Model(&amp;user).Association(<span class="hljs-string">&quot;Languages&quot;<
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Associations","level":"1.3.3","depth":2,"next":{"title":"Belongs To","level":"1.3.3.1","depth":3,"anchor":"#belongs-to","path":"associations.md","ref":"associations.md#belongs-to","articles":[]},"previous":{"title":"Conventions & Overriding","level":"1.3.2","depth":2,"anchor":"#conventions","path":"models.md","ref":"models.md#conventions","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"associations.md","mtime":"2017-10-18T10:40:29.845Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-10-18T10:41:23.502Z"},"basePath":".","book":{"language":""}}); gitbook.page.hasChanged({"page":{"title":"Associations","level":"1.3.3","depth":2,"next":{"title":"Belongs To","level":"1.3.3.1","depth":3,"anchor":"#belongs-to","path":"associations.md","ref":"associations.md#belongs-to","articles":[]},"previous":{"title":"Conventions & Overriding","level":"1.3.2","depth":2,"anchor":"#conventions","path":"models.md","ref":"models.md#conventions","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"associations.md","mtime":"2018-02-09T00:11:55.541Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
}); });
</script> </script>
</div> </div>

View File

@ -7,7 +7,7 @@
<title>Callbacks · GORM Guide</title> <title>Callbacks · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content=""> <meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2"> <meta name="generator" content="GitBook 3.2.3">
@ -602,12 +602,48 @@
</li> </li>
<li class="chapter " data-level="1.8" data-path="changelog.html"> <li class="chapter " data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.9" data-path="changelog.html">
<a href="changelog.html"> <a href="changelog.html">
<b>1.8.</b> <b>1.9.</b>
Change Log Change Log
@ -712,7 +748,7 @@ AfterFind
<span class="hljs-comment">// Rollback the insertion if user&apos;s id greater than 1000</span> <span class="hljs-comment">// Rollback the insertion if user&apos;s id greater than 1000</span>
<span class="hljs-keyword">func</span> (u *User) AfterCreate() (err error) { <span class="hljs-keyword">func</span> (u *User) AfterCreate() (err error) {
<span class="hljs-keyword">if</span> (u.Id &gt; <span class="hljs-number">1000</span>) { <span class="hljs-keyword">if</span> u.Id &gt; <span class="hljs-number">1000</span> {
err = errors.New(<span class="hljs-string">&quot;user id is already greater than 1000&quot;</span>) err = errors.New(<span class="hljs-string">&quot;user id is already greater than 1000&quot;</span>)
} }
<span class="hljs-keyword">return</span> <span class="hljs-keyword">return</span>
@ -773,7 +809,7 @@ If you want to use those changes in your callbacks, you need to run your SQL in
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Callbacks","level":"1.5","depth":1,"next":{"title":"Advanced Usage","level":"1.6","depth":1,"path":"advanced.md","ref":"advanced.md","articles":[{"title":"Error Handling","level":"1.6.1","depth":2,"anchor":"#error-handling","path":"advanced.md","ref":"advanced.md#error-handling","articles":[]},{"title":"Transactions","level":"1.6.2","depth":2,"anchor":"#transactions","path":"advanced.md","ref":"advanced.md#transactions","articles":[]},{"title":"Raw SQL & SQL Builder","level":"1.6.3","depth":2,"anchor":"#sql-builder","path":"advanced.md","ref":"advanced.md#sql-builder","articles":[]},{"title":"Generic database interface sql.DB","level":"1.6.4","depth":2,"anchor":"#generic-database-interface-sqldb","path":"advanced.md","ref":"advanced.md#generic-database-interface-sqldb","articles":[]},{"title":"Composite Primary Key","level":"1.6.5","depth":2,"anchor":"#compose-primary-key","path":"advanced.md","ref":"advanced.md#compose-primary-key","articles":[]},{"title":"Overriding Logger","level":"1.6.6","depth":2,"anchor":"#logger","path":"advanced.md","ref":"advanced.md#logger","articles":[]}]},"previous":{"title":"Associations","level":"1.4.6","depth":2,"anchor":"#associations","path":"crud.md","ref":"crud.md#associations","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"callbacks.md","mtime":"2017-10-18T10:40:29.845Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-10-18T10:41:23.502Z"},"basePath":".","book":{"language":""}}); gitbook.page.hasChanged({"page":{"title":"Callbacks","level":"1.5","depth":1,"next":{"title":"Advanced Usage","level":"1.6","depth":1,"path":"advanced.md","ref":"advanced.md","articles":[{"title":"Error Handling","level":"1.6.1","depth":2,"anchor":"#error-handling","path":"advanced.md","ref":"advanced.md#error-handling","articles":[]},{"title":"Transactions","level":"1.6.2","depth":2,"anchor":"#transactions","path":"advanced.md","ref":"advanced.md#transactions","articles":[]},{"title":"Raw SQL & SQL Builder","level":"1.6.3","depth":2,"anchor":"#sql-builder","path":"advanced.md","ref":"advanced.md#sql-builder","articles":[]},{"title":"Generic database interface sql.DB","level":"1.6.4","depth":2,"anchor":"#generic-database-interface-sqldb","path":"advanced.md","ref":"advanced.md#generic-database-interface-sqldb","articles":[]},{"title":"Composite Primary Key","level":"1.6.5","depth":2,"anchor":"#compose-primary-key","path":"advanced.md","ref":"advanced.md#compose-primary-key","articles":[]},{"title":"Overriding Logger","level":"1.6.6","depth":2,"anchor":"#logger","path":"advanced.md","ref":"advanced.md#logger","articles":[]}]},"previous":{"title":"Associations","level":"1.4.6","depth":2,"anchor":"#associations","path":"crud.md","ref":"crud.md#associations","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"callbacks.md","mtime":"2018-02-09T00:12:01.491Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
}); });
</script> </script>
</div> </div>

View File

@ -7,7 +7,7 @@
<title>Change Log · GORM Guide</title> <title>Change Log · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content=""> <meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2"> <meta name="generator" content="GitBook 3.2.3">
@ -58,7 +58,7 @@
<link rel="prev" href="development.html" /> <link rel="prev" href="dialects.html" />
</head> </head>
@ -600,12 +600,48 @@
</li> </li>
<li class="chapter active" data-level="1.8" data-path="changelog.html"> <li class="chapter " data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter active" data-level="1.9" data-path="changelog.html">
<a href="changelog.html"> <a href="changelog.html">
<b>1.8.</b> <b>1.9.</b>
Change Log Change Log
@ -731,7 +767,7 @@
<a href="development.html#write-plugins" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Write Plugins"> <a href="dialects.html#dialect-specific-columns" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Dialect Specific Columns">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
@ -743,7 +779,7 @@
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Change Log","level":"1.8","depth":1,"previous":{"title":"Write Plugins","level":"1.7.2","depth":2,"anchor":"#write-plugins","path":"development.md","ref":"development.md#write-plugins","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"changelog.md","mtime":"2017-10-18T10:40:29.846Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-10-18T10:41:23.502Z"},"basePath":".","book":{"language":""}}); gitbook.page.hasChanged({"page":{"title":"Change Log","level":"1.9","depth":1,"previous":{"title":"Dialect Specific Columns","level":"1.8.1","depth":2,"anchor":"#dialect-specific-columns","path":"dialects.md","ref":"dialects.md#dialect-specific-columns","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"changelog.md","mtime":"2018-02-09T00:11:55.542Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
}); });
</script> </script>
</div> </div>

View File

@ -7,7 +7,7 @@
<title>CRUD: Reading and Writing Data · GORM Guide</title> <title>CRUD: Reading and Writing Data · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content=""> <meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2"> <meta name="generator" content="GitBook 3.2.3">
@ -602,12 +602,48 @@
</li> </li>
<li class="chapter " data-level="1.8" data-path="changelog.html"> <li class="chapter " data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.9" data-path="changelog.html">
<a href="changelog.html"> <a href="changelog.html">
<b>1.8.</b> <b>1.9.</b>
Change Log Change Log
@ -1171,9 +1207,9 @@ DB.Model(&amp;product).Where(<span class="hljs-string">&quot;quantity &gt; 1&quo
} }
</code></pre> </code></pre>
<h3 id="extra-updating-option">Extra Updating option</h3> <h3 id="extra-updating-option">Extra Updating option</h3>
<pre><code class="lang-go">// Add extra SQL option for updating SQL <pre><code class="lang-go"><span class="hljs-comment">// Add extra SQL option for updating SQL</span>
db.Model(&amp;user).Set(&quot;gorm:update_option&quot;, &quot;OPTION (OPTIMIZE FOR UNKNOWN)&quot;).Update(&quot;name, &quot;hello&quot;) db.Model(&amp;user).Set(<span class="hljs-string">&quot;gorm:update_option&quot;</span>, <span class="hljs-string">&quot;OPTION (OPTIMIZE FOR UNKNOWN)&quot;</span>).Update(<span class="hljs-string">&quot;name&quot;</span>, <span class="hljs-string">&quot;hello&quot;</span>)
//// UPDATE users SET name=&apos;hello&apos;, updated_at = &apos;2013-11-17 21:34:10&apos; WHERE id=111 OPTION (OPTIMIZE FOR UNKNOWN); <span class="hljs-comment">//// UPDATE users SET name=&apos;hello&apos;, updated_at = &apos;2013-11-17 21:34:10&apos; WHERE id=111 OPTION (OPTIMIZE FOR UNKNOWN);</span>
</code></pre> </code></pre>
<h2 id="delete">Delete</h2> <h2 id="delete">Delete</h2>
<p><strong>WARNING</strong> When delete a record, you need to ensure it&apos;s primary field has value, and GORM will use the primary key to delete the record, if primary field&apos;s blank, GORM will delete all records for the model</p> <p><strong>WARNING</strong> When delete a record, you need to ensure it&apos;s primary field has value, and GORM will use the primary key to delete the record, if primary field&apos;s blank, GORM will delete all records for the model</p>
@ -1309,7 +1345,7 @@ db.Set(<span class="hljs-string">&quot;gorm:save_associations&quot;</span>, <spa
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"CRUD: Reading and Writing Data","level":"1.4","depth":1,"next":{"title":"Create","level":"1.4.1","depth":2,"anchor":"#create","path":"crud.md","ref":"crud.md#create","articles":[]},"previous":{"title":"Association Mode","level":"1.3.3.6","depth":3,"anchor":"#association-mode","path":"associations.md","ref":"associations.md#association-mode","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"crud.md","mtime":"2017-10-18T10:40:48.397Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-10-18T10:41:23.502Z"},"basePath":".","book":{"language":""}}); gitbook.page.hasChanged({"page":{"title":"CRUD: Reading and Writing Data","level":"1.4","depth":1,"next":{"title":"Create","level":"1.4.1","depth":2,"anchor":"#create","path":"crud.md","ref":"crud.md#create","articles":[]},"previous":{"title":"Association Mode","level":"1.3.3.6","depth":3,"anchor":"#association-mode","path":"associations.md","ref":"associations.md#association-mode","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"crud.md","mtime":"2018-02-09T00:12:01.492Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
}); });
</script> </script>
</div> </div>

View File

@ -7,7 +7,7 @@
<title>Database · GORM Guide</title> <title>Database · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content=""> <meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2"> <meta name="generator" content="GitBook 3.2.3">
@ -602,12 +602,48 @@
</li> </li>
<li class="chapter " data-level="1.8" data-path="changelog.html"> <li class="chapter " data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.9" data-path="changelog.html">
<a href="changelog.html"> <a href="changelog.html">
<b>1.8.</b> <b>1.9.</b>
Change Log Change Log
@ -689,7 +725,7 @@
) )
<span class="hljs-keyword">func</span> main() { <span class="hljs-keyword">func</span> main() {
db, err := gorm.Open(<span class="hljs-string">&quot;postgres&quot;</span>, <span class="hljs-string">&quot;host=myhost user=gorm dbname=gorm sslmode=disable password=mypassword&quot;</span>) db, err := gorm.Open(<span class="hljs-string">&quot;postgres&quot;</span>, <span class="hljs-string">&quot;host=myhost port=myport user=gorm dbname=gorm password=mypassword&quot;</span>)
<span class="hljs-keyword">defer</span> db.Close() <span class="hljs-keyword">defer</span> db.Close()
} }
</code></pre> </code></pre>
@ -830,7 +866,7 @@ db.Model(&amp;User{}).RemoveIndex(<span class="hljs-string">&quot;idx_user_name&
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Database","level":"1.2","depth":1,"next":{"title":"Database Connection","level":"1.2.1","depth":2,"anchor":"#connecting-to-a-database","path":"database.md","ref":"database.md#connecting-to-a-database","articles":[]},"previous":{"title":"Getting Started with GORM","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"database.md","mtime":"2017-10-18T10:40:29.847Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-10-18T10:41:23.502Z"},"basePath":".","book":{"language":""}}); gitbook.page.hasChanged({"page":{"title":"Database","level":"1.2","depth":1,"next":{"title":"Database Connection","level":"1.2.1","depth":2,"anchor":"#connecting-to-a-database","path":"database.md","ref":"database.md#connecting-to-a-database","articles":[]},"previous":{"title":"Getting Started with GORM","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"database.md","mtime":"2018-02-09T00:12:01.493Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
}); });
</script> </script>
</div> </div>

View File

@ -7,7 +7,7 @@
<title>Development · GORM Guide</title> <title>Development · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content=""> <meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2"> <meta name="generator" content="GitBook 3.2.3">
@ -602,12 +602,48 @@
</li> </li>
<li class="chapter " data-level="1.8" data-path="changelog.html"> <li class="chapter " data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.9" data-path="changelog.html">
<a href="changelog.html"> <a href="changelog.html">
<b>1.8.</b> <b>1.9.</b>
Change Log Change Log
@ -686,28 +722,32 @@ db.First(&amp;user)
<h2 id="write-plugins">Write Plugins</h2> <h2 id="write-plugins">Write Plugins</h2>
<p>GORM itself is powered by <code>Callbacks</code>, so you could fully customize GORM as you want</p> <p>GORM itself is powered by <code>Callbacks</code>, so you could fully customize GORM as you want</p>
<h3 id="register-a-new-callback">Register a new callback</h3> <h3 id="register-a-new-callback">Register a new callback</h3>
<pre><code>func updateCreated(scope *Scope) { <pre><code class="lang-go"><span class="hljs-keyword">func</span> updateCreated(scope *Scope) {
if scope.HasColumn(&quot;Created&quot;) { <span class="hljs-keyword">if</span> scope.HasColumn(<span class="hljs-string">&quot;Created&quot;</span>) {
scope.SetColumn(&quot;Created&quot;, NowFunc()) scope.SetColumn(<span class="hljs-string">&quot;Created&quot;</span>, NowFunc())
} }
} }
db.Callback().Create().Register(&quot;update_created_at&quot;, updateCreated) db.Callback().Create().Register(<span class="hljs-string">&quot;update_created_at&quot;</span>, updateCreated)
// register a callback for Create process <span class="hljs-comment">// register a callback for Create process</span>
</code></pre><h3 id="delete-an-existing-callback">Delete an existing callback</h3> </code></pre>
<pre><code>db.Callback().Create().Remove(&quot;gorm:create&quot;) <h3 id="delete-an-existing-callback">Delete an existing callback</h3>
// delete callback `gorm:create` from Create callbacks <pre><code class="lang-go">db.Callback().Create().Remove(<span class="hljs-string">&quot;gorm:create&quot;</span>)
</code></pre><h3 id="replace-an-existing-callback">Replace an existing callback</h3> <span class="hljs-comment">// delete callback `gorm:create` from Create callbacks</span>
<pre><code>db.Callback().Create().Replace(&quot;gorm:create&quot;, newCreateFunction) </code></pre>
// replace callback `gorm:create` with new function `newCreateFunction` for Create process <h3 id="replace-an-existing-callback">Replace an existing callback</h3>
</code></pre><h3 id="register-callback-orders">Register callback orders</h3> <pre><code class="lang-go">db.Callback().Create().Replace(<span class="hljs-string">&quot;gorm:create&quot;</span>, newCreateFunction)
<pre><code>db.Callback().Create().Before(&quot;gorm:create&quot;).Register(&quot;update_created_at&quot;, updateCreated) <span class="hljs-comment">// replace callback `gorm:create` with new function `newCreateFunction` for Create process</span>
db.Callback().Create().After(&quot;gorm:create&quot;).Register(&quot;update_created_at&quot;, updateCreated) </code></pre>
db.Callback().Query().After(&quot;gorm:query&quot;).Register(&quot;my_plugin:after_query&quot;, afterQuery) <h3 id="register-callback-orders">Register callback orders</h3>
db.Callback().Delete().After(&quot;gorm:delete&quot;).Register(&quot;my_plugin:after_delete&quot;, afterDelete) <pre><code class="lang-go">db.Callback().Create().Before(<span class="hljs-string">&quot;gorm:create&quot;</span>).Register(<span class="hljs-string">&quot;update_created_at&quot;</span>, updateCreated)
db.Callback().Update().Before(&quot;gorm:update&quot;).Register(&quot;my_plugin:before_update&quot;, beforeUpdate) db.Callback().Create().After(<span class="hljs-string">&quot;gorm:create&quot;</span>).Register(<span class="hljs-string">&quot;update_created_at&quot;</span>, updateCreated)
db.Callback().Create().Before(&quot;gorm:create&quot;).After(&quot;gorm:before_create&quot;).Register(&quot;my_plugin:before_create&quot;, beforeCreate) db.Callback().Query().After(<span class="hljs-string">&quot;gorm:query&quot;</span>).Register(<span class="hljs-string">&quot;my_plugin:after_query&quot;</span>, afterQuery)
</code></pre><h3 id="pre-defined-callbacks">Pre-Defined Callbacks</h3> db.Callback().Delete().After(<span class="hljs-string">&quot;gorm:delete&quot;</span>).Register(<span class="hljs-string">&quot;my_plugin:after_delete&quot;</span>, afterDelete)
db.Callback().Update().Before(<span class="hljs-string">&quot;gorm:update&quot;</span>).Register(<span class="hljs-string">&quot;my_plugin:before_update&quot;</span>, beforeUpdate)
db.Callback().Create().Before(<span class="hljs-string">&quot;gorm:create&quot;</span>).After(<span class="hljs-string">&quot;gorm:before_create&quot;</span>).Register(<span class="hljs-string">&quot;my_plugin:before_create&quot;</span>, beforeCreate)
</code></pre>
<h3 id="pre-defined-callbacks">Pre-Defined Callbacks</h3>
<p>GORM has defiend callbacks to perform its CRUD operations, check them out before start write your plugins</p> <p>GORM has defiend callbacks to perform its CRUD operations, check them out before start write your plugins</p>
<ul> <ul>
<li><p><a href="https://github.com/jinzhu/gorm/blob/master/callback_create.go" target="_blank">Create callbacks</a></p> <li><p><a href="https://github.com/jinzhu/gorm/blob/master/callback_create.go" target="_blank">Create callbacks</a></p>
@ -772,7 +812,7 @@ db.Callback().RowQuery().Register(<span class="hljs-string">&quot;publish:update
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Development","level":"1.7","depth":1,"next":{"title":"Architecture","level":"1.7.1","depth":2,"anchor":"#architecture","path":"development.md","ref":"development.md#architecture","articles":[]},"previous":{"title":"Overriding Logger","level":"1.6.6","depth":2,"anchor":"#logger","path":"advanced.md","ref":"advanced.md#logger","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"development.md","mtime":"2017-10-18T10:40:29.847Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-10-18T10:41:23.502Z"},"basePath":".","book":{"language":""}}); gitbook.page.hasChanged({"page":{"title":"Development","level":"1.7","depth":1,"next":{"title":"Architecture","level":"1.7.1","depth":2,"anchor":"#architecture","path":"development.md","ref":"development.md#architecture","articles":[]},"previous":{"title":"Overriding Logger","level":"1.6.6","depth":2,"anchor":"#logger","path":"advanced.md","ref":"advanced.md#logger","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"development.md","mtime":"2018-02-09T00:12:01.494Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
}); });
</script> </script>
</div> </div>

833
dialects.html Normal file
View File

@ -0,0 +1,833 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Dialects · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="dialects.html" />
<link rel="prev" href="development.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="./">
<a href="./">
<b>1.1.</b>
Getting Started with GORM
</a>
</li>
<li class="chapter " data-level="1.2" data-path="database.html">
<a href="database.html">
<b>1.2.</b>
Database
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="database.html">
<a href="database.html#connecting-to-a-database">
<b>1.2.1.</b>
Database Connection
</a>
</li>
<li class="chapter " data-level="1.2.2" data-path="database.html">
<a href="database.html#migration">
<b>1.2.2.</b>
Migration
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="models.html">
<a href="models.html">
<b>1.3.</b>
Models
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="models.html">
<a href="models.html#model-definition">
<b>1.3.1.</b>
Model Definition
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="models.html">
<a href="models.html#conventions">
<b>1.3.2.</b>
Conventions & Overriding
</a>
</li>
<li class="chapter " data-level="1.3.3" data-path="associations.html">
<a href="associations.html">
<b>1.3.3.</b>
Associations
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.3.1" data-path="associations.html">
<a href="associations.html#belongs-to">
<b>1.3.3.1.</b>
Belongs To
</a>
</li>
<li class="chapter " data-level="1.3.3.2" data-path="associations.html">
<a href="associations.html#has-one">
<b>1.3.3.2.</b>
Has One
</a>
</li>
<li class="chapter " data-level="1.3.3.3" data-path="associations.html">
<a href="associations.html#has-many">
<b>1.3.3.3.</b>
Has Many
</a>
</li>
<li class="chapter " data-level="1.3.3.4" data-path="associations.html">
<a href="associations.html#many-to-many">
<b>1.3.3.4.</b>
Many To Many
</a>
</li>
<li class="chapter " data-level="1.3.3.5" data-path="associations.html">
<a href="associations.html#polymorphism">
<b>1.3.3.5.</b>
Polymorphism
</a>
</li>
<li class="chapter " data-level="1.3.3.6" data-path="associations.html">
<a href="associations.html#association-mode">
<b>1.3.3.6.</b>
Association Mode
</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="crud.html">
<a href="crud.html">
<b>1.4.</b>
CRUD: Reading and Writing Data
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="crud.html">
<a href="crud.html#create">
<b>1.4.1.</b>
Create
</a>
</li>
<li class="chapter " data-level="1.4.2" data-path="crud.html">
<a href="crud.html#query">
<b>1.4.2.</b>
Query
</a>
</li>
<li class="chapter " data-level="1.4.3" data-path="crud.html">
<a href="crud.html#preloading-eager-loading">
<b>1.4.3.</b>
Preloading (Eager Loading)
</a>
</li>
<li class="chapter " data-level="1.4.4" data-path="crud.html">
<a href="crud.html#update">
<b>1.4.4.</b>
Update
</a>
</li>
<li class="chapter " data-level="1.4.5" data-path="crud.html">
<a href="crud.html#delete">
<b>1.4.5.</b>
Delete / Soft Delete
</a>
</li>
<li class="chapter " data-level="1.4.6" data-path="crud.html">
<a href="crud.html#associations">
<b>1.4.6.</b>
Associations
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.5" data-path="callbacks.html">
<a href="callbacks.html">
<b>1.5.</b>
Callbacks
</a>
</li>
<li class="chapter " data-level="1.6" data-path="advanced.html">
<a href="advanced.html">
<b>1.6.</b>
Advanced Usage
</a>
<ul class="articles">
<li class="chapter " data-level="1.6.1" data-path="advanced.html">
<a href="advanced.html#error-handling">
<b>1.6.1.</b>
Error Handling
</a>
</li>
<li class="chapter " data-level="1.6.2" data-path="advanced.html">
<a href="advanced.html#transactions">
<b>1.6.2.</b>
Transactions
</a>
</li>
<li class="chapter " data-level="1.6.3" data-path="advanced.html">
<a href="advanced.html#sql-builder">
<b>1.6.3.</b>
Raw SQL & SQL Builder
</a>
</li>
<li class="chapter " data-level="1.6.4" data-path="advanced.html">
<a href="advanced.html#generic-database-interface-sqldb">
<b>1.6.4.</b>
Generic database interface sql.DB
</a>
</li>
<li class="chapter " data-level="1.6.5" data-path="advanced.html">
<a href="advanced.html#compose-primary-key">
<b>1.6.5.</b>
Composite Primary Key
</a>
</li>
<li class="chapter " data-level="1.6.6" data-path="advanced.html">
<a href="advanced.html#logger">
<b>1.6.6.</b>
Overriding Logger
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.7" data-path="development.html">
<a href="development.html">
<b>1.7.</b>
Development
</a>
<ul class="articles">
<li class="chapter " data-level="1.7.1" data-path="development.html">
<a href="development.html#architecture">
<b>1.7.1.</b>
Architecture
</a>
</li>
<li class="chapter " data-level="1.7.2" data-path="development.html">
<a href="development.html#write-plugins">
<b>1.7.2.</b>
Write Plugins
</a>
</li>
</ul>
</li>
<li class="chapter active" data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.9" data-path="changelog.html">
<a href="changelog.html">
<b>1.9.</b>
Change Log
</a>
</li>
<li class="divider"></li>
</ul>
</nav>
</div>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >Dialects</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="dialects">Dialects</h1>
<!-- toc -->
<h2 id="dialect-specific-columns">Dialect Specific Columns</h2>
<p>Certain dialects of SQL ship with their own custom, non-standard column types, such as the <code>jsonb</code> column in PostgreSQL. GORM supports loading several of such types, as listed in the following sections.</p>
<h4 id="postgresql">PostgreSQL</h4>
<p>GORM supports loading the following PostgreSQL exclusive column types:</p>
<ul>
<li>jsonb</li>
<li>hstore</li>
</ul>
<p>Given the following Model definition: </p>
<pre><code class="lang-go"><span class="hljs-keyword">import</span> (
<span class="hljs-string">&quot;encoding/json&quot;</span>
<span class="hljs-string">&quot;fmt&quot;</span>
<span class="hljs-string">&quot;reflect&quot;</span>
<span class="hljs-string">&quot;github.com/jinzhu/gorm&quot;</span>
<span class="hljs-string">&quot;github.com/jinzhu/gorm/dialects/postgres&quot;</span>
)
<span class="hljs-keyword">type</span> Document <span class="hljs-keyword">struct</span> {
Metadata postgres.Jsonb
Secrets postgres.Hstore
Body <span class="hljs-keyword">string</span>
ID <span class="hljs-keyword">int</span>
}
</code></pre>
<p>You may use the model like so: </p>
<pre><code class="lang-go">password := <span class="hljs-string">&quot;0654857340&quot;</span>
metadata := json.RawMessage(<span class="hljs-string">`{&quot;is_archived&quot;: 0}`</span>)
sampleDoc := Document{
Body : <span class="hljs-string">&quot;This is a test document&quot;</span>,
Metadata : postgres.Jsonb{ metadata },
Secrets : postgres.Hstore{<span class="hljs-string">&quot;password&quot;</span> : &amp;password },
}
<span class="hljs-comment">//insert sampleDoc into the database</span>
db.Create(&amp;sampleDoc)
<span class="hljs-comment">//retrieve the fields again to confirm if they were inserted correctly</span>
resultDoc := Document{}
db.Where(<span class="hljs-string">&quot;id = ?&quot;</span>, sampleDoc.ID).First(&amp;resultDoc)
metadataIsEqual := reflect.DeepEqual( resultDoc.Metadata, sampleDoc.Metadata)
secretsIsEqual := reflect.DeepEqual( resultDoc.Secrets, resultDoc.Secrets)
<span class="hljs-comment">//this should print &quot;true&quot;</span>
fmt.Println(<span class="hljs-string">&quot;Inserted fields are as expected:&quot;</span>, metadataIsEqual &amp;&amp; secretsIsEqual)
</code></pre>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="development.html#write-plugins" class="navigation navigation-prev " aria-label="Previous page: Write Plugins">
<i class="fa fa-angle-left"></i>
</a>
<a href="dialects.html#dialect-specific-columns" class="navigation navigation-next " aria-label="Next page: Dialect Specific Columns">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Dialects","level":"1.8","depth":1,"next":{"title":"Dialect Specific Columns","level":"1.8.1","depth":2,"anchor":"#dialect-specific-columns","path":"dialects.md","ref":"dialects.md#dialect-specific-columns","articles":[]},"previous":{"title":"Write Plugins","level":"1.7.2","depth":2,"anchor":"#write-plugins","path":"development.md","ref":"development.md#write-plugins","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"dialects.md","mtime":"2018-02-09T00:12:01.494Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>
<script src="gitbook/theme.js"></script>
<script src="gitbook/gitbook-plugin-github/plugin.js"></script>
<script src="gitbook/gitbook-plugin-edit-link/plugin.js"></script>
<script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="gitbook/gitbook-plugin-search/search.js"></script>
<script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
<title>Getting Started with GORM · GORM Guide</title> <title>Getting Started with GORM · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content=""> <meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2"> <meta name="generator" content="GitBook 3.2.3">
@ -600,12 +600,48 @@
</li> </li>
<li class="chapter " data-level="1.8" data-path="changelog.html"> <li class="chapter " data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.9" data-path="changelog.html">
<a href="changelog.html"> <a href="changelog.html">
<b>1.8.</b> <b>1.9.</b>
Change Log Change Log
@ -774,7 +810,7 @@
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Getting Started with GORM","level":"1.1","depth":1,"next":{"title":"Database","level":"1.2","depth":1,"path":"database.md","ref":"database.md","articles":[{"title":"Database Connection","level":"1.2.1","depth":2,"anchor":"#connecting-to-a-database","path":"database.md","ref":"database.md#connecting-to-a-database","articles":[]},{"title":"Migration","level":"1.2.2","depth":2,"anchor":"#migration","path":"database.md","ref":"database.md#migration","articles":[]}]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"README.md","mtime":"2017-10-18T10:40:29.843Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-10-18T10:41:23.502Z"},"basePath":".","book":{"language":""}}); gitbook.page.hasChanged({"page":{"title":"Getting Started with GORM","level":"1.1","depth":1,"next":{"title":"Database","level":"1.2","depth":1,"path":"database.md","ref":"database.md","articles":[{"title":"Database Connection","level":"1.2.1","depth":2,"anchor":"#connecting-to-a-database","path":"database.md","ref":"database.md#connecting-to-a-database","articles":[]},{"title":"Migration","level":"1.2.2","depth":2,"anchor":"#migration","path":"database.md","ref":"database.md#migration","articles":[]}]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"README.md","mtime":"2018-02-09T00:11:55.539Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
}); });
</script> </script>
</div> </div>

View File

@ -7,7 +7,7 @@
<title>Models · GORM Guide</title> <title>Models · GORM Guide</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content=""> <meta name="description" content="">
<meta name="generator" content="GitBook 3.2.2"> <meta name="generator" content="GitBook 3.2.3">
@ -602,12 +602,48 @@
</li> </li>
<li class="chapter " data-level="1.8" data-path="changelog.html"> <li class="chapter " data-level="1.8" data-path="dialects.html">
<a href="dialects.html">
<b>1.8.</b>
Dialects
</a>
<ul class="articles">
<li class="chapter " data-level="1.8.1" data-path="dialects.html">
<a href="dialects.html#dialect-specific-columns">
<b>1.8.1.</b>
Dialect Specific Columns
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.9" data-path="changelog.html">
<a href="changelog.html"> <a href="changelog.html">
<b>1.8.</b> <b>1.9.</b>
Change Log Change Log
@ -752,10 +788,11 @@ db.SingularTable(<span class="hljs-literal">true</span>) <span class="hljs-comme
</code></pre> </code></pre>
<h3 id="change-default-tablenames">Change default tablenames</h3> <h3 id="change-default-tablenames">Change default tablenames</h3>
<p>You can apply any rules on the default table name by defining the <code>DefaultTableNameHandler</code></p> <p>You can apply any rules on the default table name by defining the <code>DefaultTableNameHandler</code></p>
<pre><code>gorm.DefaultTableNameHandler = func (db *gorm.DB, defaultTableName string) string { <pre><code class="lang-go">gorm.DefaultTableNameHandler = <span class="hljs-keyword">func</span> (db *gorm.DB, defaultTableName <span class="hljs-keyword">string</span>) <span class="hljs-keyword">string</span> {
return &quot;prefix_&quot; + defaultTableName; <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;prefix_&quot;</span> + defaultTableName;
} }
</code></pre><h3 id="column-name-is-the-snake-case-of-fields-name">Column name is the snake case of field&apos;s name</h3> </code></pre>
<h3 id="column-name-is-the-snake-case-of-fields-name">Column name is the snake case of field&apos;s name</h3>
<pre><code class="lang-go"><span class="hljs-keyword">type</span> User <span class="hljs-keyword">struct</span> { <pre><code class="lang-go"><span class="hljs-keyword">type</span> User <span class="hljs-keyword">struct</span> {
ID <span class="hljs-keyword">uint</span> <span class="hljs-comment">// column name will be `id`</span> ID <span class="hljs-keyword">uint</span> <span class="hljs-comment">// column name will be `id`</span>
Name <span class="hljs-keyword">string</span> <span class="hljs-comment">// column name will be `name`</span> Name <span class="hljs-keyword">string</span> <span class="hljs-comment">// column name will be `name`</span>
@ -841,7 +878,7 @@ db.Model(&amp;user).Update(<span class="hljs-string">&quot;name&quot;</span>, <s
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Models","level":"1.3","depth":1,"next":{"title":"Model Definition","level":"1.3.1","depth":2,"anchor":"#model-definition","path":"models.md","ref":"models.md#model-definition","articles":[]},"previous":{"title":"Migration","level":"1.2.2","depth":2,"anchor":"#migration","path":"database.md","ref":"database.md#migration","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"models.md","mtime":"2017-10-18T10:40:29.850Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-10-18T10:41:23.502Z"},"basePath":".","book":{"language":""}}); gitbook.page.hasChanged({"page":{"title":"Models","level":"1.3","depth":1,"next":{"title":"Model Definition","level":"1.3.1","depth":2,"anchor":"#model-definition","path":"models.md","ref":"models.md#model-definition","articles":[]},"previous":{"title":"Migration","level":"1.2.2","depth":2,"anchor":"#migration","path":"database.md","ref":"database.md#migration","articles":[]},"dir":"ltr"},"config":{"plugins":["github","edit-link"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"fontsettings":{"theme":"night","family":"sans","size":2},"github":{"url":"https://github.com/jinzhu/gorm"},"edit-link":{"label":"Edit This Page","base":"https://github.com/jinzhu/gorm/edit/gh-pages/documents/"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"GORM Guide","gitbook":"*"},"file":{"path":"models.md","mtime":"2018-02-09T00:12:01.495Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-02-09T00:14:37.173Z"},"basePath":".","book":{"language":""}});
}); });
</script> </script>
</div> </div>

File diff suppressed because one or more lines are too long