spark.spec-tacular.schema

Creating Datomic schemas from specifications

diff

(diff schema1 schema2)

Returns the difference between two schemas as three sets: * the entries only in schema1, * the entries only in schema2, * the entries in both schema1 and schema2

EntityMap

An EntityMap is a (possibly partial) description of a Datomic entity.

from-database

(from-database db)

Returns the Schema in the given Database, Connection, or spark.spec-tacular.datomic/ConnCtx.

from-file

(from-file schema-file)

Returns the Schema inside the given file

from-namespace

(from-namespace namespace)

Converts all specs in namespace into a Schema

from-spec

(from-spec spec-kw)

Generates a Schema that represents spec.

from-specs

(from-specs specs)

Converts a sequence of specs (which may be actual spec objects or keywords) into a Schema

InstallableEntityMap

A a full description of a Datomic entity that can be installed as part of a Datomic schema.

normalize

(normalize schema)

Normalizes schema for comparison:

  • removes any mappings for attributes that Datomic adds automatically
  • removes :db/id and :db.install/_attribute attributes from each mapping
  • ensures each entry has a :db/unique attribute, even if it’s nil
  • simplifies :db/fn fields so that they are comparable with =

read

(read stream)

Returns the Schema inside the given stream

read-string

(read-string s)

Returns the Schema inside the given string

Schema

A list of mappings that can be used as a Datomic schema. Schemas can be created from sequences or namespaces containing defspecs, or can be recreated from files and databases.

spec-tacular-map

The map for the special :spec-tacular/spec ident which must be installed on any database hoping to use spec-tacular. Automatically installed when using to-database!.

to-database!

(to-database! schema)(to-database! schema uri)

Creates a fresh database with schema installed and returns a connection to that database. If the schema does not already contain spec-tacular-map, it is added.

Installs at uri if supplied.

to-file

(to-file schema file)

Writes schema to file, returns nil.

URI

A URI is just a string, but it should probably look like "datomic:mem://<squiid>"

write

Writes the schema to w, adding in spec-tacular-map.