Closed orestis closed 5 years ago
A similar use case would be to be able to generate vectors of relation ids. I'm not sure what the relation syntax would look, but the result should look something like this:
;; site
{:id 1
:name "etc etc"
:clients [2 3 4]}
Where [2 3 4]
are ids that point to some other entity, e.g. user
and have to be unique.
I have a feeling that this could be done in a post-processing visitation function though?
the :clients
use case is already handled with :coll
relation types :) check out this test and the related schema
Your initial suggestion is something I'll need to spend more time looking into. I think it should be supported but I haven't touched the codebase in a while, and I'm not sure how difficult it would be to accomplish or what priority it should be :)
This feature is really useful
:constraints {:some/key #{:coll}}
but it is not clearly documented. I discovered it by looking in this issue.
I'd suggest that this is added to the readme (already awesome) so that others can more easily learn how to populate n-arity relations declaratively.
One more "feature" related to :coll constraints that would be useful is the ability to ensure the sort/order of the inserted values. currently it's variable. Let me know if you would like me to create a new issue for this?
After quite some time I've finally been able to look at it. One potential issue is that in
:relations {[:meta :client_id] [:client :id]}
It's ambiguous as to whether [:meta :client_id]
is meant to represent a path into a map, or a top-level key on a map. However, there is a workaround, which is to create your own spec-gen visitor.
Here is where a referenced value gets associated with the ent referencing it. This is part of a 3-step process for using spec to generate values. You could replace that second step with one of your own that interprets vectors as paths and uses assoc-in
instead of assoc
. Hope this helps, even though it's like 5000 years later 📦
I'm evaluating Specmonstah to generate test data for Mongodb. I'd like to be able to specify paths for relations, instead of only top-level keys. Example:
With the expectation that the generated
site
entity will look like this:Does that sound reasonable?