fluree.db.api
address?
(address? ledger-alias-or-address)
Returns true if the argument is a full ledger address, false if it is just an
alias.
alias->address
(alias->address conn ledger-alias)
Returns a core.async channel with the connection-specific address of the
given ledger-alias.
commit!
(commit! ledger db)
(commit! ledger db opts)
Commits a staged database to the ledger with all changes since the last commit
aggregated together.
Commits are tracked in the local environment, but if the ledger is distributed
it will still need a 'push' to ensure it is published and verified as per the
distributed rules.
connect
(connect config)
Forms connection to ledger, enabling automatic pulls of new updates, event
services, index service.
Multiple connections to same endpoint will share underlying network
connection.
Options include:
- did - (optional) DId information to use, if storing blocks as verifiable
credentials, or issuing queries against a permissioned database.
connect-file
(connect-file)
(connect-file {:keys [storage-path parallelism cache-max-mb defaults], :or {storage-path "data", parallelism 4, cache-max-mb 1000}})
connect-memory
(connect-memory)
(connect-memory {:keys [parallelism cache-max-mb defaults], :or {parallelism 4, cache-max-mb 1000}})
Forms an in-memory connection using default settings.
- did - (optional) DId information to use, if storing blocks as verifiable credentials
convert-config-key
(convert-config-key [k v])
convert-keys
(convert-keys m)
create
(create conn ledger-alias)
(create conn ledger-alias opts)
Creates a new json-ld ledger. A connection (conn)
must always be supplied.
Ledger-name (optional) is a friendly name that is used for:
- When publishing to a naming service that allows multiple pointers for the
same namespace (e.g. IPNS), this becomes a sub-directory off the namespace.
For multple directories deep, use '/' for a
e.g. the ledgers movies/popular, books/authors, books/best-sellers could
use the same IPNS id (in this example using IPNS DNSLink):
fluree:ipns://my.dns.com/books/authors
fluree:ipns://my.dns.com/books/best-sellers
fluree:ipns://my.dns.com/movies/top-rated
- When combining multiple ledgers, each ledger becomes an individual named
graph which can be referenced by name.
Options map (opts) can include:
- did - DId information to use, if storing blocks as verifiable credentials
create-with-txn
(create-with-txn conn txn)
(create-with-txn conn txn opts)
credential-history
(credential-history ledger cred-query)
(credential-history ledger cred-query override-opts)
Issues a policy-enforced history query to the specified ledger as a
verifiable credential.
Extracts the query from the credential, and cryptographically verifies the
signing identity, which is then used by `wrap-identity-policy` to extract
the policy classes and apply the policies to the query.
credential-query
(credential-query ds cred-query)
(credential-query ds cred-query {:keys [values-map format], :as opts})
Issues a policy-enforced query to the specified dataset/db as a verifiable
credential.
Extracts the query from the credential, and cryptographically verifies the
signing identity, which is then used by `wrap-identity-policy` to extract
the policy classes and apply the policies to the query.
credential-query-connection
(credential-query-connection conn cred-query)
(credential-query-connection conn cred-query {:keys [format], :as opts})
credential-transact!
(credential-transact! conn txn)
(credential-transact! conn txn opts)
dataset
(dataset named-graphs)
(dataset named-graphs default-graphs)
Creates a composed dataset from multiple resolved graph databases.
The databases to be composed are supplied as a map with a string alias
as they key, and the resolved graph db as the value.
By default, every resolved graph db will be composed together as a new
default graph which will be used for all where clauses in queries that
do *not* specify a specific graph to target, which is done using the
special `graph` syntax in the where clause.
If just one or more of the supplied graph dbs should instead be used as
the default graph (instead of all of them), supply the second argument
as a list of the db aliases in the db-map that should be used as the
default.
Targeting a single named graph in a query (as opposed to the default graph)
is done by using the `graph` syntax within the 'where' clause, for example:
{...
'where': [...
['graph' <graph-alias> <query-pattern>]]
...}
db
(db ledger)
Retrieves latest db, or optionally a db at a moment in time
and/or permissioned to a specific identity.
decode-iri
(decode-iri db iri)
Opposite of encode-iri. When doing more advanced features
like direct range-scans of indexes, IRIs are returned in their
internal compact format. This allows the IRI to be returned
as a full string IRI.
disconnect
(disconnect conn)
drop
(drop conn ledger-alias)
encode-iri
(encode-iri db iri)
Returns the internal Fluree IRI identifier (a compact form).
This can be used for doing range scans, slices and for other
more advanced needs.
exists?
(exists? conn ledger-alias-or-address)
Returns a promise with true if the ledger alias or address exists, false
otherwise.
expand-iri
(expand-iri context compact-iri)
Expands given IRI with the default database context, or provided context.
history
(history ledger query)
(history ledger query override-opts)
Return the change history over a specified time range. Optionally include the commit
that produced the changes.
insert
(insert db json-ld)
(insert db json-ld opts)
Inserts a new set of data into the database if valid (does not commit).
Multiple inserts and updates can be staged together and will be merged into a single
transaction when committed.
Supports JSON-LD (default) and Turtle (TTL) formats.
The 'opts' key is a map with the following key options:
- `:context` - (optional) and externally provided context that will be used
for JSON-LD document expansition, the @context in the json-ld
will be ignored if present.
- `:format` - (optional) the format of the data, currently json-ld is assumed
unless `:format` is set to `:turtle`. If `:turtle` is set,
the `:context` option will be ignored if provided.
load
(load conn alias-or-address)
Loads an existing ledger by its alias (which will be converted to a
connection-specific address first).
notify
(notify conn commit-address commit-hash)
Notifies the connection of a new commit stored at address `commit-address`.
If the connection knows of the ledger, and is currently maintaining an
in-memory version of the ledger, will attempt to update the db if the commit
is for the next 't' value. If a commit is for a past 't' value, noop. If
commit is for a future 't' value, will drop in-memory ledger for reload upon
next request.
promise-wrap
(promise-wrap port)
Wraps an async channel that will contain a response in a promise.
query
(query ds q)
(query ds q opts)
Queries a dataset or single db and returns a promise with the results.
query-connection
(query-connection conn q)
(query-connection conn q opts)
Queries the latest db in the ledger specified by the 'from' parameter in the
query (what that actually looks like is format-specific). Returns a promise
with the results.
range
(range db index test match)
(range db index start-test start-match end-test end-match)
Performs a range scan against the specified index using test functions
of >=, <=, >, <
reason
(reason db methods)
(reason db methods rule-sources)
(reason db methods rule-sources opts)
Sets the reasoner methods(s) to perform on a db.
Supported methods are :datalog and :owl2rl.
One or more methods can be supplied as a sequential list/vector.
Reasoning is done in-memory at the db-level and is not persisted.
A rules graph containing rules in JSON-LD format can be supplied,
or if no rules graph is supplied, the rules will be looked for within
the db itself.
reasoned-count
(reasoned-count db)
Returns a count of reasoned facts in the provided db.
reasoned-facts
(reasoned-facts db)
(reasoned-facts db opts)
Returns all reasoned facts in the provided db as 4-tuples of:
[subject property object rule-iri]
where the rule-iri is the @id of the rule that generated the fact
Returns 4-tuples of where
the rule-iri is the @id of the rule that generated the fact.
NOTE: Currently returns internal fluree ids for subject, property and object.
This will be changed to return IRIs in a future release.
Optional opts map specified grouping, or no grouping (default):
{:group-by :rule} - group by rule IRI
{:group-by :subject} - group by the reasoned triples' subject
{:group-by ::property} - group by the reasoned triples' property IRI
slice
(slice db index match)
Like range, but returns all flakes that match the supplied flake parts.
stage
(stage db json-ld)
(stage db json-ld opts)
Renamed to `update`, prefer that API instead.
status
(status ledger)
(status ledger branch)
Returns current status of ledger branch.
transact!
(transact! conn txn)
(transact! conn txn opts)
update
(update db json-ld)
(update db json-ld opts)
Performs an update and queues change if valid (does not commit).
Multiple updates can be staged together and will be merged into a single
transaction when committed.
upsert
(upsert db json-ld)
(upsert db json-ld opts)
Performs an upsert operation, which will insert the data if it does not exist,
or update the existing data if it does. This is useful for ensuring that a
specific document is present in the database with the desired values.
Supports JSON-LD and Turtle (TTL) formats.
The 'opts' key is a map with the following key options:
- `:context` - (optional) and externally provided context that will be used
for document expansion, the @context in the json-ld will be
ignored if present.
- `:format` - (optional) the format of the data, currently json-ld is assumed
unless `:format` is set to `:turtle`. If `:turtle` is set,
the `:context` option will be ignored if provided.
The data is expected to be in JSON-LD format, and will be expanded before
being inserted into the database.
wrap-class-policy
(wrap-class-policy db policy-classes)
(wrap-class-policy db policy-classes policy-values)
Restricts the provided db with policies in the db
which have a class @type of the provided class(es).
wrap-identity-policy
(wrap-identity-policy db identity)
(wrap-identity-policy db identity policy-values)
For provided identity, locates specific property f:policyClass on
the identity containing a list of class IRIs that identity the policies
that should be applied to the identity.
With the policy classes, finds all policies containing that class
declaration.
wrap-policy
(wrap-policy db policy)
(wrap-policy db policy policy-values)
Restricts the provided db with the provided json-ld
policy restrictions