1
0

tex: add more stuff on db config+ent

This commit is contained in:
leo 2023-05-25 05:10:32 +02:00
parent 2f349a1e3c
commit 6f0f6abe4a
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

@ -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}