tex: add more stuff on db config+ent
This commit is contained in:
parent
2f349a1e3c
commit
6f0f6abe4a
33
tex/text.tex
33
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}
|
||||
|
||||
|
Reference in New Issue
Block a user