From 6f0f6abe4a5c817aef248fa14ca06b947cbe1ae0 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 25 May 2023 05:10:32 +0200 Subject: [PATCH] tex: add more stuff on db config+ent --- tex/text.tex | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/tex/text.tex b/tex/text.tex index 0665059..d04c9ef 100644 --- a/tex/text.tex +++ b/tex/text.tex @@ -1338,22 +1338,31 @@ way that the empty/partial records would be dropped entirely. \n{2}{Database configuration} -The database schema is not created manually in the database, instead, an -Object-relational Mapping (ORM) tool named ent is used. This allows defining -the table schema and relations entirely in Go. The best part about ent is that -there is not need to define supplemental methods on the models, since ent -employs \emph{code generation}, which creates these based on the types of the -attributes in the model and the respective relations. For instance, if an -attribute is a string value \texttt{Email}, ent can be used to generate code -that contains methods on the user object like the following: +The database schema is not being created manually in the database. Instead, an +Object-relational Mapping (ORM) tool named ent is used, which allows defining +the table schema and relations entirely in Go. + +The best part about ent is that there is no need to define supplemental methods +on the models, since with ent these are meant to be \emph{code generated} (in +the older sense of word, not with Large Language Models). That creates files +with models based on the types of the attributes in the database model and the +respective relations are transformed into methods on the receiver and functions +taking object attributes as arguments. + +For instance, if the model's attribute is a string value \texttt{Email}, ent +can be used to generate code that contains methods on the user object like the +following: \begin{itemize} -\item EmailIn -\item EmailEQ -\item EmailNEQ -\item EmailHasSuffix +\item \texttt{EmailIn(pattern string)} +\item \texttt{EmailEQ(email string)} +\item \texttt{EmailNEQ(email string)} +\item \texttt{EmailHasSuffix(suffix string)} \end{itemize} +These methods can further be imported into other packages and makes working +with the database a morning breeze. + \n{1}{Production}