Liking cljdoc? Tell your friends :D

com.fulcrologic.rad.database-adapters.datomic

cljs

This ns exists for aliasing purposes only.

This ns exists for aliasing purposes only.
raw docstring

adapt-external-database!clj

(adapt-external-database! conn schema all-attributes)

Adds necessary transactor functions and verifies schema of a Datomic database that is not under the control of this adapter, but is used by it.

Adds necessary transactor functions and verifies schema of a Datomic database that is not
under the control of this adapter, but is used by it.
sourceraw docstring

automatic-schemaclj

(automatic-schema attributes schema-name)

Returns a Datomic transaction for the complete schema of the supplied RAD attributes that have a ::datomic/schema that matches schema-name.

Returns a Datomic transaction for the complete schema of the supplied RAD `attributes`
that have a `::datomic/schema` that matches `schema-name`.
sourceraw docstring

config->free-urlclj

(config->free-url {:free/keys [host port] datomic-db :datomic/database})
source

config->mysql-urlclj

(config->mysql-url {:mysql/keys [user host port password database]
                    datomic-db :datomic/database})
source

config->postgres-urlclj

(config->postgres-url {:postgresql/keys [user host port password database]
                       datomic-db :datomic/database})
source

config->urlclj

(config->url {:datomic/keys [driver] :as config})
source

delete-entity!clj

(delete-entity! {:com.fulcrologic.rad.attributes/keys [key->attribute] :as env}
                [pk id :as ident])

Delete the given entity, if possible.

Delete the given entity, if possible.
sourceraw docstring

delta->txnclj

(delta->txn env schema delta)
source

empty-db-connectionclj

(empty-db-connection all-attributes schema-name)
(empty-db-connection all-attributes schema-name txn)

Returns a Datomic database that contains the given application schema, but no data. This function must be passed a schema name (keyword). The optional second parameter is the actual schema to use in the empty database, otherwise automatic generation will be used against RAD attributes. This function memoizes the resulting database for speed.

See reset-test-schema.

Returns a Datomic database that contains the given application schema, but no data.
This function must be passed a schema name (keyword).  The optional second parameter
is the actual schema to use in the empty database, otherwise automatic generation will be used
against RAD attributes. This function memoizes the resulting database for speed.

See `reset-test-schema`.
sourceraw docstring

ensure-transactor-functions!clj

(ensure-transactor-functions! conn)

Must be called on any Datomic database that will be used with automatic form save. This adds transactor functions. The built-in startup logic (if used) will automatically call this, but if you create/start your databases with custom code you should run this on your newly created database.

Must be called on any Datomic database that will be used with automatic form save. This
adds transactor functions.  The built-in startup logic (if used) will automatically call this,
but if you create/start your databases with custom code you should run this on your newly
created database.
sourceraw docstring

entity-queryclj

(entity-query {:com.fulcrologic.rad.database-adapters.datomic/keys
                 [schema id-attribute]
               :com.fulcrologic.rad.attributes/keys [attributes]
               :as env}
              input)
source

failsafe-idclj

(failsafe-id {:com.fulcrologic.rad.attributes/keys [key->attribute] :as env}
             ident)

Returns a fail-safe id for the given ident in a transaction. A fail-safe ID will be one of the following:

  • A long (:db/id) for a pre-existing entity.
  • A string that stands for a temporary :db/id within the transaction if the id of the ident is temporary.
  • A lookup ref (the ident itself) if the ID uses a non-native ID, and it is not a tempid.
  • A keyword if it is a keyword (a :db/ident)
Returns a fail-safe id for the given ident in a transaction. A fail-safe ID will be one of the following:

- A long (:db/id) for a pre-existing entity.
- A string that stands for a temporary :db/id within the transaction if the id of the ident is temporary.
- A lookup ref (the ident itself) if the ID uses a non-native ID, and it is not a tempid.
- A keyword if it is a keyword (a :db/ident)
sourceraw docstring

generate-next-idclj

(generate-next-id {:com.fulcrologic.rad.attributes/keys [key->attribute]
                   :as env}
                  k)
source

generate-resolversclj

(generate-resolvers attributes schema)

Generate all of the resolvers that make sense for the given database config. This should be passed to your Pathom parser to register resolvers for each of your schemas.

Generate all of the resolvers that make sense for the given database config. This should be passed
to your Pathom parser to register resolvers for each of your schemas.
sourceraw docstring

get-by-idsclj

(get-by-ids db ids db-idents desired-output)
source

id-resolverclj

(id-resolver {:com.fulcrologic.rad.attributes/keys [qualified-key]
              :com.fulcrologic.rad.database-adapters.datomic/keys [schema
                                                                   wrap-resolve]
              :as id-attribute}
             output-attributes)

Generates a resolver from id-attribute to the output-attributes.

Generates a resolver from `id-attribute` to the `output-attributes`.
sourceraw docstring

keys-in-deltaclj

source

mock-resolver-envclj

(mock-resolver-env schema connection)

Returns a mock env that has the ::connections and ::databases keys that would be present in a properly-set-up pathom resolver env for a given single schema. This should be called after you have seeded data against a connection that goes with the given schema.

  • schema - A schema name
  • connection - A database connection that is connected to a database with that schema.
Returns a mock env that has the ::connections and ::databases keys that would be present in
a properly-set-up pathom resolver `env` for a given single schema. This should be called *after*
you have seeded data against a `connection` that goes with the given schema.

* `schema` - A schema name
* `connection` - A database connection that is connected to a database with that schema.
sourceraw docstring

native-ident?clj

(native-ident? {:com.fulcrologic.rad.attributes/keys [key->attribute] :as env}
               ident)

Returns true if the given ident is using a database native ID (:db/id)

Returns true if the given ident is using a database native ID (:db/id)
sourceraw docstring

next-uuidclj

(next-uuid)
source

pathom-pluginclj

(pathom-plugin database-mapper)

A pathom plugin that adds the necessary Datomic connections and databases to the pathom env for a given request. Requires a database-mapper, which is a (fn [pathom-env] {schema-name connection}) for a given request.

The resulting pathom-env available to all resolvers will then have:

  • ::datomic/connections: The result of database-mapper
  • ::datomic/databases: A map from schema name to atoms holding a database. The atom is present so that a mutation that modifies the database can choose to update the snapshot of the db being used for the remaining resolvers.

This plugin should run before (be listed after) most other plugins in the plugin chain since it adds connection details to the parsing env.

A pathom plugin that adds the necessary Datomic connections and databases to the pathom env for
a given request. Requires a database-mapper, which is a
`(fn [pathom-env] {schema-name connection})` for a given request.

The resulting pathom-env available to all resolvers will then have:

- `::datomic/connections`: The result of database-mapper
- `::datomic/databases`: A map from schema name to atoms holding a database. The atom is present so that
a mutation that modifies the database can choose to update the snapshot of the db being used for the remaining
resolvers.

This plugin should run before (be listed after) most other plugins in the plugin chain since
it adds connection details to the parsing env.
sourceraw docstring

pristine-db-connectionclj

(pristine-db-connection)

Returns a Datomic database that has no application schema or data.

Returns a Datomic database that has no application schema or data.
sourceraw docstring

pull-*clj

(pull-* db pattern db-idents eid-or-eids)
(pull-* db pattern ident-keywords eid-or-eids transform-fn)

Will either call d/pull or d/pull-many depending on if the input is sequential or not.

Optionally takes in a transform-fn, applies to individual result(s).

Will either call d/pull or d/pull-many depending on if the input is
sequential or not.

Optionally takes in a transform-fn, applies to individual result(s).
sourceraw docstring

ref?clj

(ref? {:com.fulcrologic.rad.attributes/keys [key->attribute]} k)
source

replace-ref-typesclj

(replace-ref-types db refs arg)

dbc the database to query refs a set of keywords that ref datomic entities, which you want to access directly (rather than retrieving the entity id) m map returned from datomic pull containing the entity IDs you want to deref

dbc   the database to query
refs  a set of keywords that ref datomic entities, which you want to access directly
       (rather than retrieving the entity id)
m     map returned from datomic pull containing the entity IDs you want to deref
sourceraw docstring

reset-migrated-dbs!clj

(reset-migrated-dbs!)

Forget the cached versions of test databases obtained from empty-db-connection.

Forget the cached versions of test databases obtained from empty-db-connection.
sourceraw docstring

save-form!clj

(save-form! env {:com.fulcrologic.rad.form/keys [delta] :as save-params})

Do all of the possible Datomic operations for the given form delta (save to all Datomic databases involved)

Do all of the possible Datomic operations for the given form delta (save to all Datomic databases involved)
sourceraw docstring

schema-value?clj

(schema-value? {:com.fulcrologic.rad.attributes/keys [key->attribute]}
               target-schema
               k)
source

schemas-for-deltaclj

(schemas-for-delta {:com.fulcrologic.rad.attributes/keys [key->attribute]}
                   delta)
source

start-database!clj

(start-database! all-attributes
                 {:datomic/keys [schema prevent-changes?] :as config}
                 schemas)

Starts a Datomic database connection given the standard sub-element config described in start-databases. Typically use that function instead of this one.

NOTE: This function relies on the attribute registry, which you must populate before calling this.

`all-attributes

  • :config a map of k-v pairs for setting up a connection.
  • schemas a map from schema name to either :auto, :none, or (fn [conn]).

Returns a migrated database connection.

Starts a Datomic database connection given the standard sub-element config described
in `start-databases`. Typically use that function instead of this one.

NOTE: This function relies on the attribute registry, which you must populate before
calling this.

`all-attributes

* `:config` a map of k-v pairs for setting up a connection.
* `schemas` a map from schema name to either :auto, :none, or (fn [conn]).

Returns a migrated database connection.
sourceraw docstring

start-databasesclj

(start-databases all-attributes config)
(start-databases all-attributes config schemas)

Start all of the databases described in config, using the schemas defined in schemas.

  • config: a map that contains the key ::datomic/databases.
  • schemas: a map whose keys are schema names, and whose values can be missing (or :auto) for automatic schema generation, a (fn [schema-name conn] ...) that updates the schema for schema-name on the database reachable via conn. You may omit schemas if automatic generation is being used everywhere.

WARNING: Be sure all of your model files are required before running this function, since it will use the attribute definitions during startup.

The ::datomic/databases entry in the config is a map with the following form:

{:production-shard-1 {:datomic/schema :production
                      :datomic/driver :postgresql
                      :datomic/database "prod"
                      :postgresql/host "localhost"
                      :postgresql/port "localhost"
                      :postgresql/user "datomic"
                      :postgresql/password "datomic"
                      :postgresql/database "datomic"}}

The :datomic/schema is used to select the attributes that will appear in that database's schema. The remaining parameters select and configure the back-end storage system for the database.

Each supported driver type has custom options for configuring it. See Fulcro's config file support for a good method of defining these in EDN config files for use in development and production environments.

Returns a map whose keys are the database keys (i.e. :production-shard-1) and whose values are the live database connection.

Start all of the databases described in config, using the schemas defined in schemas.

* `config`:  a map that contains the key ::datomic/databases.
* `schemas`:  a map whose keys are schema names, and whose values can be missing (or :auto) for
automatic schema generation, a `(fn [schema-name conn] ...)` that updates the schema for schema-name
on the database reachable via `conn`. You may omit `schemas` if automatic generation is being used
everywhere.

WARNING: Be sure all of your model files are required before running this function, since it
will use the attribute definitions during startup.

The `::datomic/databases` entry in the config is a map with the following form:

```
{:production-shard-1 {:datomic/schema :production
                      :datomic/driver :postgresql
                      :datomic/database "prod"
                      :postgresql/host "localhost"
                      :postgresql/port "localhost"
                      :postgresql/user "datomic"
                      :postgresql/password "datomic"
                      :postgresql/database "datomic"}}
```

The `:datomic/schema` is used to select the attributes that will appear in that database's schema.
The remaining parameters select and configure the back-end storage system for the database.

Each supported driver type has custom options for configuring it. See Fulcro's config
file support for a good method of defining these in EDN config files for use in development
and production environments.

Returns a map whose keys are the database keys (i.e. `:production-shard-1`) and
whose values are the live database connection.
sourceraw docstring

suggested-logging-blacklistclj

A vector containing a list of namespace strings that generate a lot of debug noise when using Datomic. Can be added to Timbre's ns-blacklist to reduce logging overhead.

A vector containing a list of namespace strings that generate a lot of debug noise when using Datomic. Can
be added to Timbre's ns-blacklist to reduce logging overhead.
sourceraw docstring

tempid->intermediate-idclj

(tempid->intermediate-id {:com.fulcrologic.rad.attributes/keys [key->attribute]}
                         delta)
source

tempids->generate-idsclj

(tempids->generate-ids {:com.fulcrologic.rad.attributes/keys [key->attribute]
                        :as env}
                       delta)
source

to-many-txnclj

(to-many-txn env schema delta)
source

to-one-txnclj

(to-one-txn env schema delta)
source

to-one?clj

(to-one? {:com.fulcrologic.rad.attributes/keys [key->attribute]} k)
source

tx-valueclj

(tx-value env k v)

Convert v to a transaction-safe value based on its type and cardinality.

Convert `v` to a transaction-safe value based on its type and cardinality.
sourceraw docstring

type-mapclj

source

uuid-ident?clj

(uuid-ident? {:com.fulcrologic.rad.attributes/keys [key->attribute] :as env}
             ident)

Returns true if the ID in the given ident uses UUIDs for ids.

Returns true if the ID in the given ident uses UUIDs for ids.
sourceraw docstring

verify-schema!clj

(verify-schema! db schema all-attributes)

Validate that a database supports then named schema. This function finds all attributes that are declared on the schema, and checks that the Datomic representation of them meets minimum requirements for desired operation.

This function throws an exception if a problem is found, and can be used in applications that manage their own schema to ensure that the database will operate correctly in RAD.

Validate that a database supports then named `schema`. This function finds all attributes
that are declared on the schema, and checks that the Datomic representation of them
meets minimum requirements for desired operation.

This function throws an exception if a problem is found, and can be used in
applications that manage their own schema to ensure that the database will
operate correctly in RAD.
sourceraw docstring

wrap-datomic-deleteclj

(wrap-datomic-delete)
(wrap-datomic-delete handler)

Form delete middleware to accomplish datomic deletes.

Form delete middleware to accomplish datomic deletes.
sourceraw docstring

wrap-datomic-saveclj

(wrap-datomic-save)
(wrap-datomic-save handler)

Form save middleware to accomplish Datomic saves.

Form save middleware to accomplish Datomic saves.
sourceraw docstring

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

× close