sm/add-ents
, as in ex-01
above. This section explains how to define ent types and the relationship between ent types and ent graph generation.:user
and :post
above) and each ent type's definition is a map with the keys :prefix
and (usually) :relations
. These values are used to generate ent graphs.:prefix
is used to name ents. If you want to add three users with (sm/add-ents {:schema schema} {:user [[3]]})
, the :user
ent type's :prefix
of :u
is used to generate ents named :u0
, :u1
, and :u2
. There's a pattern here: every generated ent is named :{schema-prefix}{index}
.:relations
defines how ents reference each other. The :post
definition includes {:relations {:owner-id [:user :id]}}
, specifying that a :post
should reference a :user
. The relation also specifies that the :post
's :owner-id
should be set to the :user
's :id
, information that will be used when we use spec-gen to generate records for these ents. (Covered in a later section).:relations
are also what allow Specmonstah queries to be concise. :user
should be created, but Specmonstah knows to add one because the :post
ent type's :relations
key specifies that :post
s reference a :user
.:post
ent type and :user
ent type. You can also define more than one ent type per database table; if you find yourself often testing authentication scenarios, for example, you could create an :invalid-user
ent type and write code that would insert the data for those ents into your user
table (how to do this will be clear by the end of the tutorial). Ent type names are not in any way magical, you should use whatever names are most convenient for you.