"use strict";(self.webpackChunkgoffee_site=self.webpackChunkgoffee_site||[]).push([[8340],{9508:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>f,frontMatter:()=>a,metadata:()=>r,toc:()=>d});var o=t(4848),s=t(8453);const a={title:"Database Configuration"},i=void 0,r={id:"database-config",title:"Database Configuration",description:"Goffee uses GORM to query the database, all the features of GORM are available for you to use. Supported databases are mysql, postgres and sqlite",source:"@site/docs/database-config.md",sourceDirName:".",slug:"/database-config",permalink:"/goffee/docs/database-config",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"Database Configuration"},sidebar:"docsSidebar",previous:{title:"Events",permalink:"/goffee/docs/events"},next:{title:"Models",permalink:"/goffee/docs/database-models"}},c={},d=[{value:"Enable GORM",id:"enable-gorm",level:3},{value:"The database connection config",id:"the-database-connection-config",level:4}];function l(e){const n={a:"a",code:"code",h3:"h3",h4:"h4",p:"p",pre:"pre",...(0,s.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(n.p,{children:["Goffee uses ",(0,o.jsx)(n.a,{href:"https://gorm.io/",children:"GORM"})," to query the database, all the features of ",(0,o.jsx)(n.code,{children:"GORM"})," are available for you to use. Supported databases are ",(0,o.jsx)(n.code,{children:"mysql"}),", ",(0,o.jsx)(n.code,{children:"postgres"})," and ",(0,o.jsx)(n.code,{children:"sqlite"})]}),"\n",(0,o.jsx)(n.h3,{id:"enable-gorm",children:"Enable GORM"}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"GORM"})," is disabled by default, you can enable it in the file ",(0,o.jsx)(n.code,{children:"condfig/gorm.go"})," by setting the attribute ",(0,o.jsx)(n.code,{children:"EnableGorm"})," to ",(0,o.jsx)(n.code,{children:"true"})]}),"\n",(0,o.jsx)(n.h4,{id:"the-database-connection-config",children:"The database connection config"}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.code,{children:"GORM configuration"})," can be set in the ",(0,o.jsx)(n.code,{children:".env"})," file, the configuration also can be injected into the environment by using an external tool\nHere is a sample of the configuration:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"#######################################\n######            DATABASE       ######\n#######################################\nDB_DRIVER=mysql  # mysql | postgres | sqlite\n#_____ MYSQL _____#\nMYSQL_HOST=localhost\nMYSQL_DB_NAME=db_test\nMYSQL_PORT=3306\nMYSQL_USERNAME=root\nMYSQL_PASSWORD=secret\nMYSQL_CHARSET=utf8mb4\n\n#_____ postgres _____#\nPOSTGRES_HOST=localhost\nPOSTGRES_USER=user\nPOSTGRES_PASSWORD=secret\nPOSTGRES_DB_NAME=db_test\nPOSTGRES_PORT=5432\nPOSTGRES_SSL_MODE=disable\nPOSTGRES_TIMEZONE=Asia/Dubai\n\n#_____ SQLITE _____#\nSQLITE_DB_PATH=storage/sqlite/db.sqlite\n"})})]})}function f(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(l,{...e})}):l(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>r});var o=t(6540);const s={},a=o.createContext(s);function i(e){const n=o.useContext(a);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),o.createElement(a.Provider,{value:n},e.children)}}}]);