Liking cljdoc? Tell your friends :D

donut.datapotato.core


add-edge-with-idclj/s

(add-edge-with-id g ent-name related-ent-name id)

When indicating :ent-a references :ent-b, include a :relation-attrs graph attribute that includes the attributes via which :ent-a references :ent-b.

For example, if the :project named :p0 has an :owner-id and :updated-by-id that both reference the :user named :u0, then the edge from :p0 to :u0 will if a :relation-attrs attribute with value #{:owner-id :updated-by-id}.

This can be used e.g. to set the values for :owner-id and :updated-by-id.

When indicating :ent-a references :ent-b, include a
`:relation-attrs` graph attribute that includes the attributes via
which `:ent-a` references `:ent-b`.

For example, if the `:project` named `:p0` has an `:owner-id` and
`:updated-by-id` that both reference the `:user` named `:u0`, then
the edge from `:p0` to `:u0` will if a `:relation-attrs` attribute
with value `#{:owner-id :updated-by-id}`.

This can be used e.g. to set the values for `:owner-id` and
`:updated-by-id`.
raw docstring

add-entclj/s

(add-ent {:keys [data] :as db} ent-name ent-type query-term)

Add an ent, and its related ents, to the ent-db

Add an ent, and its related ents, to the ent-db
raw docstring

add-ent-type-queryclj/s

(add-ent-type-query db ent-type-query ent-type)

A query is composed of ent-type-queries, where each ent-type-query specifies the ents that should be created for that type. This function adds the ents for an ent-type-query.

A query is composed of ent-type-queries, where each ent-type-query
specifies the ents that should be created for that type. This
function adds the ents for an ent-type-query.
raw docstring

add-entsclj/s

(add-ents {:keys [schema] :as db} query)

Produce a new db with an ent graph that contains all ents specified by query

Produce a new db with an ent graph that contains all ents specified
by query
raw docstring

add-n-entsclj/s

(add-n-ents db ent-type num-ents query-term)

Used when a query is something like [3]

Used when a query is something like [3]
raw docstring

add-ref-entsclj/s

(add-ref-ents db)

Ents are added in two stages: first, all ents that are declared in the query are added. During that process, we keep track of ref-ents, ents which are automatically generated in order to satisfy relations. This function adds those ref ents if an ent of the same name doesn't exist already.

Ents are added in two stages: first, all ents that are declared in
the query are added. During that process, we keep track of ref-ents,
ents which are automatically generated in order to satisfy
relations. This function adds those ref ents if an ent of the same
name doesn't exist already.
raw docstring

(add-related-ents {:keys [data] :as db} ent-name ent-type query-term)

all-ent-relationsclj/s

(all-ent-relations db)
(all-ent-relations db ents)

Given a db, returns a map of ent-type to map of entity relations.

An example return value is: {:patient {:p0 {:created-by :u0 :updated-by :u1} :p1 {:created-by :u0 :updated-by :u2}} :user {:u0 {:friends-with :u0}}}

Given a db, returns a map of ent-type to map of entity relations.

An example return value is:
{:patient {:p0 {:created-by :u0
                :updated-by :u1}
           :p1 {:created-by :u0
                :updated-by :u2}}
 :user {:u0 {:friends-with :u0}}}
raw docstring

assoc-referenced-valclj/s

(assoc-referenced-val ent-data relation-attr relation-val constraints)

Look up related ent's attr value and assoc with parent ent attr. :coll relations will add value to a vector.

Look up related ent's attr value and assoc with parent ent
attr. `:coll` relations will add value to a vector.
raw docstring

assoc-referenced-valsclj/s

(assoc-referenced-vals db {:keys [ent-name visit-key visit-val]})

A visiting function that sets referenced values.

Given a schema like {:user {} :post {:relations {:created-by [:user :id]}}}

a :post's :created-by key gets set to the :id of the :user it references.

A visiting function that sets referenced values.

Given a schema like
{:user {}
 :post {:relations {:created-by [:user :id]}}}

a :post's `:created-by` key gets set to the `:id` of the :user it references.
raw docstring

attr-mapclj/s

(attr-map db attr)
(attr-map {:keys [data] :as _db} attr ents)

Produce a map where each key is a node and its value is a graph attr on that node

Produce a map where each key is a node and its value is a graph
attr on that node
raw docstring

bound-descendants?clj/s

(bound-descendants? {:keys [relation-graph]} query-bindings related-ent-type)

Check whether query-relations contains bindings that apply to any descendants of related-ent-type

Check whether `query-relations` contains bindings that apply to any
descendants of `related-ent-type`
raw docstring

bound-relation-attr-nameclj/s

(bound-relation-attr-name {:keys [schema]} ent-name related-ent-type index)

Template for when a binding necessitates you add a new entity

Template for when a binding necessitates you add a new entity
raw docstring

bound-relation-attr-name-sourceclj/s

(bound-relation-attr-name-source ent-name)

coll-relation-attr?clj/s

(coll-relation-attr? db ent relation-attr)

Given a db, ent, and relation-attr, determines whether the relation is a coll attr.

Given a db, ent, and relation-attr, determines whether the relation is
a coll attr.
raw docstring

conformed-query-optsclj/s

(conformed-query-opts query-term relation-attr)

These conformed query opts allow us to 1) validate the query term and 2) dispatch on what kind of query was supplied.

This is one of the most complicated parts of SM because users can supply different types of values for the :refs key of a query:

  1. an ent-name for unary relations (type: :ent-name)
  2. a vector of ent-names for coll relations (type: :ent-names)
  3. a number for coll relations (type: :ent-count)

These types are captured by the ::refs specs, and the specs it composes. The type for the supplied query-term is returned as :qr-type.

Each of these qr-types corresponds to a constraint of either :coll or :unary. The constraint is returned as :qr-constraint.

Conforming the query opts provides the qr-type and qr-constraint so that dependent functions can dispatch on these values.

These conformed query opts allow us to 1) validate the query term and
2) dispatch on what kind of query was supplied.

This is one of the most complicated parts of SM because users can
supply different types of values for the `:refs` key of a query:

1. an ent-name for unary relations          (type: `:ent-name`)
2. a vector of ent-names for coll relations (type: `:ent-names`)
3. a number for coll relations              (type: `:ent-count`)

These types are captured by the `::refs` specs, and the specs it
composes. The type for the supplied query-term is returned as
`:qr-type`.

Each of these qr-types corresponds to a constraint of either `:coll`
or `:unary`. The constraint is returned as `:qr-constraint`.

Conforming the query opts provides the `qr-type` and `qr-constraint`
so that dependent functions can dispatch on these values.
raw docstring

default-node-nameclj/s

(default-node-name {:keys [schema]} ent-type)

Whenever datapotato needs to create a node that's not manually named, it uses this to generate the default name.

Whenever datapotato needs to create a node that's not manually
named, it uses this to generate the default name.
raw docstring

ent-attrclj/s

(ent-attr {:keys [data]} ent-name attr)

ent-attrsclj/s

(ent-attrs {:keys [data]} ent-name)

ent-indexclj/s

(ent-index g ent-type)

Used to keep track of entity's insertion order in graph relative to other entities of the same type.

Used to keep track of entity's insertion order in graph relative to
other entities of the same type.
raw docstring

(ent-related-by-attr? db ent-name related-ent relation-attr)

Is ent A related to ent B by the given relation-attr?

Is ent A related to ent B by the given relation-attr?
raw docstring

ent-relation-constraintsclj/s

(ent-relation-constraints db ent relation-attr)

ent-relationsclj/s

(ent-relations db ent)

Given a db and an ent, returns a map of relation attr to ent-name.

Given a db and an ent, returns a map of relation attr to ent-name.
raw docstring

ent-schemaclj/s

(ent-schema {:keys [schema data]} ent-name)

Given an ent name, return the schema of its corresponding type

Given an ent name, return the schema of its corresponding type
raw docstring

entsclj/s

(ents {:keys [data]})

returns all ents in the ent db

returns all ents in the ent db
raw docstring

ents-by-typeclj/s

(ents-by-type db)
(ents-by-type db ents)

Given a db, returns a map of ent-type to a set of entities of that type. Optionally pass in a seq of the ents that should be included.

Given a db, returns a map of ent-type to a set of entities of that
type. Optionally pass in a seq of the ents that should be included.
raw docstring

identical-prefixesclj/s

(identical-prefixes schema)

Schemas are invalid if two types have the same prefix. This checks that.

Schemas are invalid if two types have the same prefix. This checks
that.
raw docstring

incrementing-node-nameclj/s

(incrementing-node-name {:keys [data schema]} ent-type)

A template for creating distinct node names.

A template for creating distinct node names.
raw docstring

init-dbclj/s

(init-db {:keys [schema] :as db} query)

invalid-constraintsclj/s

(invalid-constraints schema)

Constraints that reference nonexistent relation attrs

Constraints that reference nonexistent relation attrs
raw docstring

invalid-schema-relationsclj/s

(invalid-schema-relations schema)

Relations that reference nonexistent types

Relations that reference nonexistent types
raw docstring

merge-overwritesclj/s

(merge-overwrites _db {:keys [visit-val visit-query-opts schema-opts]})

Overwrites generated data with what's found in schema-opts or visit-query-opts.

Overwrites generated data with what's found in schema-opts or
visit-query-opts.
raw docstring

numeric-node-nameclj/s

(numeric-node-name schema ent-type index)

Template for generating a node name

Template for generating a node name
raw docstring

omit-relation?clj/s

(omit-relation? db ent-name reference-key)

omit?clj/s

(omit? x)

prune-requiredclj/s

(prune-required {:keys [data] :as db} required-attrs)

Updates ent graph, removing edges going from a 'required' ent to the 'requiring' ent, thus eliminating cycles.

Updates ent graph, removing edges going from a 'required' ent to the
'requiring' ent, thus eliminating cycles.
raw docstring

query-entsclj/s

(query-ents {:keys [data] :as _db})

Get seq of nodes that are explicitly defined in the query

Get seq of nodes that are explicitly defined in the query
raw docstring

query-optsclj/s

(query-opts {:keys [data]} ent-name)

query-relationclj/s

(query-relation db ent-name relation-attr)

Returns the conformed relation for an ent's relation-attr. Handles polymorphic relations.

Returns the conformed relation for an ent's relation-attr. Handles
polymorphic relations.
raw docstring

referenced-ent-attrsclj/s

(referenced-ent-attrs {:keys [data] :as db} ent-name)

seq of [referenced-ent relation-attr]

seq of [referenced-ent relation-attr]
raw docstring

(related-ents {:keys [schema data] :as db}
              ent-name
              relation-attr
              related-ent-type
              query-term)

Returns all related ents for an ent's relation-attr

Returns all related ents for an ent's relation-attr
raw docstring

(related-ents-by-attr {:keys [data] :as db} ent-name relation-attr)

All ents related to ent via relation-attr

All ents related to ent via relation-attr
raw docstring

relation-attrsclj/s

(relation-attrs {:keys [data]} ent-name referenced-ent)

Given an ent A and an ent it references B, return the set of attrs by which A references B.

Given an ent A and an ent it references B, return the set of attrs
by which A references B.
raw docstring

relation-attrs-with-constraintclj/s

(relation-attrs-with-constraint db ent-name _constraint)

Given an ent name, return all relation attributes which include the constraint.

Given an ent name, return all relation attributes which include the constraint.
raw docstring

relation-graphclj/s

(relation-graph schema)

A graph of the type dependencies in a schema. If entities of type :project reference an entity of type :user via :owner-id, then this will return a graph where the :project node connects to the :user node

A graph of the type dependencies in a schema. If entities of type
`:project` reference an entity of type `:user` via `:owner-id`, then
this will return a graph where the `:project` node connects to the
`:user` node
raw docstring

required-attrsclj/s

(required-attrs {:keys [schema]})

Returns a map of {:ent-type #{:required-attr-1 :required-attr-2}}. Used to handle cycles.

Returns a map of `{:ent-type #{:required-attr-1 :required-attr-2}}`.
Used to handle cycles.
raw docstring

reset-relationsclj/s

(reset-relations db {:keys [ent-name visit-val]})

Generated data generates values agnostic of any schema constraints that may be present. This function updates values in the generated data to match up with constraints. First, it will remove any dummy ID's for a :coll relation. Next, it will remove any dummy ID's generated for an :omit relation. The updated ent-data map will be returned.

Generated data generates values agnostic of any schema constraints that may be
present. This function updates values in the generated data to match up with
constraints. First, it will remove any dummy ID's for a `:coll` relation.
Next, it will remove any dummy ID's generated for an `:omit` relation. The
updated ent-data map will be returned.
raw docstring

sort-by-requiredclj/s

(sort-by-required db)

sort-entsclj/s

(sort-ents db)

Attempts to topsort ents. If that's not possible (cycles present), uses sort-by-required to resolve ordering of ents in cycle

Attempts to topsort ents. If that's not possible (cycles present),
uses `sort-by-required` to resolve ordering of ents in cycle
raw docstring

throw-invalid-specclj/s

(throw-invalid-spec arg-name spec data)

topsort-entsclj/s

(topsort-ents {:keys [data]})

uniq-relation-attr?clj/s

(uniq-relation-attr? db ent relation-attr)

Given a db, ent, and relation-attr, determines whether the relation is a uniq attr.

Given a db, ent, and relation-attr, determines whether the relation is
a uniq attr.
raw docstring

(validate-related-ents-query db ent-name relation-attr query-term)

Check that the refs value supplied in a query is a collection if the relation type is collection, or a keyword if the relation type is unary. If the reference is omit, no further validation is required.

Check that the refs value supplied in a query is a collection if the
relation type is collection, or a keyword if the relation type is
unary. If the reference is omit, no further validation is required.
raw docstring

viewclj

(view {:keys [data]})

View with loom

View with loom
raw docstring

visit-entsclj/s

(visit-ents db visit-key visit-fns)
(visit-ents db visit-key visit-fns ents)

Perform visit-fns on ents, storing return value as a graph attribute under visit-key

Perform `visit-fns` on ents, storing return value as a graph
attribute under `visit-key`
raw docstring

visit-ents-onceclj/s

(visit-ents-once db visit-key visit-fns)
(visit-ents-once db visit-key visit-fns ents)

Like visit-ents but doesn't call visit-fn if the ent already has a visit-key attribute

Like `visit-ents` but doesn't call `visit-fn` if the ent already
has a `visit-key` attribute
raw docstring

visit-fn-dataclj/s

(visit-fn-data db ent visit-key)

When a visit fn is called, it's passed this map as its second argument

When a visit fn is called, it's passed this map as its second argument
raw docstring

wrap-gen-data-visiting-fnclj/s

(wrap-gen-data-visiting-fn data-generating-visiting-fn)

Useful when writing visiting fns where data generated for ent A needs to be referenced by ent B.

Useful when writing visiting fns where data generated for ent A needs to be
referenced by ent B.
raw docstring

wrap-incremental-insert-visiting-fnclj/s

(wrap-incremental-insert-visiting-fn source-key inserting-visiting-fn)

Takes generated data stored as an attributed under source-key and inserts it using inserting-visiting-fn.

Respects overwrites and ensures that referenced vals are assoc'd in before inserting. Useful when dealing with db-generated ids.

Takes generated data stored as an attributed under `source-key` and inserts it
using `inserting-visiting-fn`.

Respects overwrites and ensures that referenced vals are assoc'd in before
inserting. Useful when dealing with db-generated ids.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close