datahike 0.7.1630
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -0
- package/cljs.analyzer.api.js +427 -0
- package/cljs.analyzer.api.js.map +1 -0
- package/cljs.analyzer.impl.js +86 -0
- package/cljs.analyzer.impl.js.map +1 -0
- package/cljs.analyzer.impl.namespaces.js +219 -0
- package/cljs.analyzer.impl.namespaces.js.map +1 -0
- package/cljs.analyzer.js +7186 -0
- package/cljs.analyzer.js.map +1 -0
- package/cljs.analyzer.passes.and_or.js +141 -0
- package/cljs.analyzer.passes.and_or.js.map +1 -0
- package/cljs.analyzer.passes.js +104 -0
- package/cljs.analyzer.passes.js.map +1 -0
- package/cljs.cache.js +1145 -0
- package/cljs.cache.js.map +1 -0
- package/cljs.cache.wrapped.js +352 -0
- package/cljs.cache.wrapped.js.map +1 -0
- package/cljs.core.async.impl.buffers.js +489 -0
- package/cljs.core.async.impl.buffers.js.map +1 -0
- package/cljs.core.async.impl.channels.js +711 -0
- package/cljs.core.async.impl.channels.js.map +1 -0
- package/cljs.core.async.impl.dispatch.js +81 -0
- package/cljs.core.async.impl.dispatch.js.map +1 -0
- package/cljs.core.async.impl.ioc_helpers.js +192 -0
- package/cljs.core.async.impl.ioc_helpers.js.map +1 -0
- package/cljs.core.async.impl.protocols.js +368 -0
- package/cljs.core.async.impl.protocols.js.map +1 -0
- package/cljs.core.async.impl.timers.js +510 -0
- package/cljs.core.async.impl.timers.js.map +1 -0
- package/cljs.core.async.js +8813 -0
- package/cljs.core.async.js.map +1 -0
- package/cljs.core.js +38764 -0
- package/cljs.core.js.map +1 -0
- package/cljs.env.js +60 -0
- package/cljs.env.js.map +1 -0
- package/cljs.nodejs.js +80 -0
- package/cljs.nodejs.js.map +1 -0
- package/cljs.reader.js +462 -0
- package/cljs.reader.js.map +1 -0
- package/cljs.spec.alpha.js +5312 -0
- package/cljs.spec.alpha.js.map +1 -0
- package/cljs.spec.gen.alpha.js +2020 -0
- package/cljs.spec.gen.alpha.js.map +1 -0
- package/cljs.tagged_literals.js +103 -0
- package/cljs.tagged_literals.js.map +1 -0
- package/cljs.tools.reader.edn.js +960 -0
- package/cljs.tools.reader.edn.js.map +1 -0
- package/cljs.tools.reader.impl.commons.js +217 -0
- package/cljs.tools.reader.impl.commons.js.map +1 -0
- package/cljs.tools.reader.impl.errors.js +441 -0
- package/cljs.tools.reader.impl.errors.js.map +1 -0
- package/cljs.tools.reader.impl.inspect.js +182 -0
- package/cljs.tools.reader.impl.inspect.js.map +1 -0
- package/cljs.tools.reader.impl.utils.js +429 -0
- package/cljs.tools.reader.impl.utils.js.map +1 -0
- package/cljs.tools.reader.js +1830 -0
- package/cljs.tools.reader.js.map +1 -0
- package/cljs.tools.reader.reader_types.js +838 -0
- package/cljs.tools.reader.reader_types.js.map +1 -0
- package/cljs_env.js +18192 -0
- package/cljs_node_io.core.js +1278 -0
- package/cljs_node_io.core.js.map +1 -0
- package/cljs_node_io.file.js +918 -0
- package/cljs_node_io.file.js.map +1 -0
- package/cljs_node_io.fs.js +3911 -0
- package/cljs_node_io.fs.js.map +1 -0
- package/clojure.data.js +319 -0
- package/clojure.data.js.map +1 -0
- package/clojure.edn.js +119 -0
- package/clojure.edn.js.map +1 -0
- package/clojure.set.js +406 -0
- package/clojure.set.js.map +1 -0
- package/clojure.string.js +502 -0
- package/clojure.string.js.map +1 -0
- package/clojure.walk.js +156 -0
- package/clojure.walk.js.map +1 -0
- package/datahike.api.impl.js +621 -0
- package/datahike.api.impl.js.map +1 -0
- package/datahike.api.specification.js +85 -0
- package/datahike.api.specification.js.map +1 -0
- package/datahike.array.js +275 -0
- package/datahike.array.js.map +1 -0
- package/datahike.config.js +437 -0
- package/datahike.config.js.map +1 -0
- package/datahike.connections.js +55 -0
- package/datahike.connections.js.map +1 -0
- package/datahike.connector.js +1248 -0
- package/datahike.connector.js.map +1 -0
- package/datahike.constants.js +66 -0
- package/datahike.constants.js.map +1 -0
- package/datahike.core.js +628 -0
- package/datahike.core.js.map +1 -0
- package/datahike.datom.js +963 -0
- package/datahike.datom.js.map +1 -0
- package/datahike.db.interface.js +819 -0
- package/datahike.db.interface.js.map +1 -0
- package/datahike.db.js +3095 -0
- package/datahike.db.js.map +1 -0
- package/datahike.db.search.js +1004 -0
- package/datahike.db.search.js.map +1 -0
- package/datahike.db.transaction.js +1904 -0
- package/datahike.db.transaction.js.map +1 -0
- package/datahike.db.utils.js +642 -0
- package/datahike.db.utils.js.map +1 -0
- package/datahike.gc.js +1618 -0
- package/datahike.gc.js.map +1 -0
- package/datahike.impl.entity.js +604 -0
- package/datahike.impl.entity.js.map +1 -0
- package/datahike.index.interface.js +484 -0
- package/datahike.index.interface.js.map +1 -0
- package/datahike.index.js +50 -0
- package/datahike.index.js.map +1 -0
- package/datahike.index.persistent_set.js +1250 -0
- package/datahike.index.persistent_set.js.map +1 -0
- package/datahike.js.api.js +2211 -0
- package/datahike.js.api.js.map +1 -0
- package/datahike.lru.js +404 -0
- package/datahike.lru.js.map +1 -0
- package/datahike.pull_api.js +533 -0
- package/datahike.pull_api.js.map +1 -0
- package/datahike.query.js +11891 -0
- package/datahike.query.js.map +1 -0
- package/datahike.query_stats.js +152 -0
- package/datahike.query_stats.js.map +1 -0
- package/datahike.readers.js +166 -0
- package/datahike.readers.js.map +1 -0
- package/datahike.schema.js +251 -0
- package/datahike.schema.js.map +1 -0
- package/datahike.schema_cache.js +66 -0
- package/datahike.schema_cache.js.map +1 -0
- package/datahike.spec.js +70 -0
- package/datahike.spec.js.map +1 -0
- package/datahike.store.js +514 -0
- package/datahike.store.js.map +1 -0
- package/datahike.tools.js +436 -0
- package/datahike.tools.js.map +1 -0
- package/datahike.writer.js +3463 -0
- package/datahike.writer.js.map +1 -0
- package/datahike.writing.js +3168 -0
- package/datahike.writing.js.map +1 -0
- package/datalog.parser.impl.js +1421 -0
- package/datalog.parser.impl.js.map +1 -0
- package/datalog.parser.impl.proto.js +213 -0
- package/datalog.parser.impl.proto.js.map +1 -0
- package/datalog.parser.impl.util.js +117 -0
- package/datalog.parser.impl.util.js.map +1 -0
- package/datalog.parser.js +47 -0
- package/datalog.parser.js.map +1 -0
- package/datalog.parser.pull.js +2603 -0
- package/datalog.parser.pull.js.map +1 -0
- package/datalog.parser.type.js +7502 -0
- package/datalog.parser.type.js.map +1 -0
- package/datalog.parser.util.js +60 -0
- package/datalog.parser.util.js.map +1 -0
- package/environ.core.js +263 -0
- package/environ.core.js.map +1 -0
- package/fress.api.js +607 -0
- package/fress.api.js.map +1 -0
- package/fress.impl.adler32.js +435 -0
- package/fress.impl.adler32.js.map +1 -0
- package/fress.impl.bigint.js +185 -0
- package/fress.impl.bigint.js.map +1 -0
- package/fress.impl.buffer.js +1087 -0
- package/fress.impl.buffer.js.map +1 -0
- package/fress.impl.codes.js +105 -0
- package/fress.impl.codes.js.map +1 -0
- package/fress.impl.hopmap.js +603 -0
- package/fress.impl.hopmap.js.map +1 -0
- package/fress.impl.ranges.js +49 -0
- package/fress.impl.ranges.js.map +1 -0
- package/fress.impl.raw_input.js +837 -0
- package/fress.impl.raw_input.js.map +1 -0
- package/fress.impl.raw_output.js +653 -0
- package/fress.impl.raw_output.js.map +1 -0
- package/fress.impl.table.js +133 -0
- package/fress.impl.table.js.map +1 -0
- package/fress.reader.js +2312 -0
- package/fress.reader.js.map +1 -0
- package/fress.util.js +458 -0
- package/fress.util.js.map +1 -0
- package/fress.writer.js +2141 -0
- package/fress.writer.js.map +1 -0
- package/geheimnis.aes.js +132 -0
- package/geheimnis.aes.js.map +1 -0
- package/hasch.base64.js +42 -0
- package/hasch.base64.js.map +1 -0
- package/hasch.benc.js +201 -0
- package/hasch.benc.js.map +1 -0
- package/hasch.core.js +188 -0
- package/hasch.core.js.map +1 -0
- package/hasch.platform.js +221 -0
- package/hasch.platform.js.map +1 -0
- package/incognito.base.js +276 -0
- package/incognito.base.js.map +1 -0
- package/incognito.edn.js +54 -0
- package/incognito.edn.js.map +1 -0
- package/incognito.fressian.js +330 -0
- package/incognito.fressian.js.map +1 -0
- package/index.d.ts +660 -0
- package/is.simm.partial_cps.async.js +142 -0
- package/is.simm.partial_cps.async.js.map +1 -0
- package/is.simm.partial_cps.runtime.js +65 -0
- package/is.simm.partial_cps.runtime.js.map +1 -0
- package/is.simm.partial_cps.sequence.js +1255 -0
- package/is.simm.partial_cps.sequence.js.map +1 -0
- package/konserve.cache.js +2519 -0
- package/konserve.cache.js.map +1 -0
- package/konserve.compressor.js +502 -0
- package/konserve.compressor.js.map +1 -0
- package/konserve.core.js +8052 -0
- package/konserve.core.js.map +1 -0
- package/konserve.encryptor.js +553 -0
- package/konserve.encryptor.js.map +1 -0
- package/konserve.gc.js +541 -0
- package/konserve.gc.js.map +1 -0
- package/konserve.impl.defaults.js +8290 -0
- package/konserve.impl.defaults.js.map +1 -0
- package/konserve.impl.storage_layout.js +849 -0
- package/konserve.impl.storage_layout.js.map +1 -0
- package/konserve.memory.js +2102 -0
- package/konserve.memory.js.map +1 -0
- package/konserve.node_filestore.js +2951 -0
- package/konserve.node_filestore.js.map +1 -0
- package/konserve.protocols.js +590 -0
- package/konserve.protocols.js.map +1 -0
- package/konserve.serializers.js +562 -0
- package/konserve.serializers.js.map +1 -0
- package/konserve.store.js +2245 -0
- package/konserve.store.js.map +1 -0
- package/konserve.tiered.js +9574 -0
- package/konserve.tiered.js.map +1 -0
- package/konserve.utils.js +180 -0
- package/konserve.utils.js.map +1 -0
- package/me.tonsky.persistent_sorted_set.arrays.js +66 -0
- package/me.tonsky.persistent_sorted_set.arrays.js.map +1 -0
- package/me.tonsky.persistent_sorted_set.branch.js +2779 -0
- package/me.tonsky.persistent_sorted_set.branch.js.map +1 -0
- package/me.tonsky.persistent_sorted_set.btset.js +14196 -0
- package/me.tonsky.persistent_sorted_set.btset.js.map +1 -0
- package/me.tonsky.persistent_sorted_set.impl.node.js +324 -0
- package/me.tonsky.persistent_sorted_set.impl.node.js.map +1 -0
- package/me.tonsky.persistent_sorted_set.impl.storage.js +123 -0
- package/me.tonsky.persistent_sorted_set.impl.storage.js.map +1 -0
- package/me.tonsky.persistent_sorted_set.js +890 -0
- package/me.tonsky.persistent_sorted_set.js.map +1 -0
- package/me.tonsky.persistent_sorted_set.leaf.js +561 -0
- package/me.tonsky.persistent_sorted_set.leaf.js.map +1 -0
- package/me.tonsky.persistent_sorted_set.util.js +402 -0
- package/me.tonsky.persistent_sorted_set.util.js.map +1 -0
- package/medley.core.js +1857 -0
- package/medley.core.js.map +1 -0
- package/package.json +38 -0
- package/spec_tools.core.js +1925 -0
- package/spec_tools.core.js.map +1 -0
- package/spec_tools.data_spec.js +1291 -0
- package/spec_tools.data_spec.js.map +1 -0
- package/spec_tools.form.js +185 -0
- package/spec_tools.form.js.map +1 -0
- package/spec_tools.impl.js +362 -0
- package/spec_tools.impl.js.map +1 -0
- package/spec_tools.parse.js +427 -0
- package/spec_tools.parse.js.map +1 -0
- package/spec_tools.transform.js +288 -0
- package/spec_tools.transform.js.map +1 -0
- package/superv.async.js +8617 -0
- package/superv.async.js.map +1 -0
- package/tailrecursion.priority_map.js +994 -0
- package/tailrecursion.priority_map.js.map +1 -0
- package/taoensso.encore.js +12385 -0
- package/taoensso.encore.js.map +1 -0
- package/taoensso.timbre.appenders.core.js +239 -0
- package/taoensso.timbre.appenders.core.js.map +1 -0
- package/taoensso.timbre.js +1264 -0
- package/taoensso.timbre.js.map +1 -0
- package/taoensso.truss.impl.js +442 -0
- package/taoensso.truss.impl.js.map +1 -0
- package/taoensso.truss.js +743 -0
- package/taoensso.truss.js.map +1 -0
- package/test-config-keys.js +33 -0
- package/test-final.js +36 -0
- package/test-key-duplication.js +67 -0
- package/test.js +557 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
// Auto-generated TypeScript definitions for Datahike JavaScript API
|
|
2
|
+
// DO NOT EDIT - Generated from datahike.api.specification
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// Core Datahike Types
|
|
6
|
+
|
|
7
|
+
export interface DatabaseConfig {
|
|
8
|
+
store: {
|
|
9
|
+
backend: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
'keep-history'?: boolean;
|
|
15
|
+
'schema-flexibility'?: 'read' | 'write';
|
|
16
|
+
'initial-tx'?: Transaction[];
|
|
17
|
+
name?: string;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Connection {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Database {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type Transaction =
|
|
30
|
+
| [':db/add', number | string, string, any]
|
|
31
|
+
| [':db/retract', number | string, string, any]
|
|
32
|
+
| { [key: string]: any };
|
|
33
|
+
|
|
34
|
+
export interface TransactionReport {
|
|
35
|
+
'db-before': Database;
|
|
36
|
+
'db-after': Database;
|
|
37
|
+
'tx-data': Datom[];
|
|
38
|
+
tempids: { [key: string]: number };
|
|
39
|
+
'tx-meta'?: any;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface Datom {
|
|
43
|
+
e: number;
|
|
44
|
+
a: string;
|
|
45
|
+
v: any;
|
|
46
|
+
tx: number;
|
|
47
|
+
added: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface Schema {
|
|
51
|
+
[key: string]: {
|
|
52
|
+
'db/valueType': string;
|
|
53
|
+
'db/cardinality': string;
|
|
54
|
+
'db/unique'?: string;
|
|
55
|
+
'db/index'?: boolean;
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface Metrics {
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// API Functions
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns the database state at given point in time (you may use either java.util.Date or transaction ID as long).
|
|
69
|
+
*
|
|
70
|
+
* (transact conn {:tx-data [{:db/ident :name
|
|
71
|
+
* :db/valueType :db.type/string
|
|
72
|
+
* :db/unique :db.unique/identity
|
|
73
|
+
* :db/index true
|
|
74
|
+
* :db/cardinality :db.cardinality/one}
|
|
75
|
+
* {:db/ident :age
|
|
76
|
+
* :db/valueType :db.type/long
|
|
77
|
+
* :db/cardinality :db.cardinality/one}]})
|
|
78
|
+
*
|
|
79
|
+
* (transact conn {:tx-data [{:name "Alice" :age 25} {:name "Bob" :age 30}]})
|
|
80
|
+
*
|
|
81
|
+
* (def date (java.util.Date.))
|
|
82
|
+
*
|
|
83
|
+
* (transact conn {:tx-data [{:db/id [:name "Alice"] :age 35}]})
|
|
84
|
+
*
|
|
85
|
+
* (q {:query '[:find ?n ?a :where [?e :name ?n] [?e :age ?a]]
|
|
86
|
+
* :args [(as-of @conn date)]}) ; => #{["Alice" 25] ["Bob" 30]}
|
|
87
|
+
*
|
|
88
|
+
* (q {:query '[:find ?n ?a :where [?e :name ?n] [?e :age ?a]]
|
|
89
|
+
* :args [@conn]}) ; => #{["Alice" 35] ["Bob" 30]}
|
|
90
|
+
*/
|
|
91
|
+
export function asOf(db?: Database, timePoint?: any): Promise<Database>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Connects to a datahike database via configuration map. For more information on the configuration refer to the [docs](https://github.com/replikativ/datahike/blob/master/doc/config.md).
|
|
95
|
+
*
|
|
96
|
+
* The configuration for a connection is a subset of the Datahike configuration with only the store necessary: `:store`.
|
|
97
|
+
*
|
|
98
|
+
* `:store` defines the backend configuration as hash-map with mandatory key: `:backend` and store dependent keys.
|
|
99
|
+
*
|
|
100
|
+
* Per default Datahike ships with `:memory` and `:file` backend.
|
|
101
|
+
*
|
|
102
|
+
* The default configuration:
|
|
103
|
+
* `{:store {:backend :memory :id "default"}}`
|
|
104
|
+
*
|
|
105
|
+
* Usage:
|
|
106
|
+
*
|
|
107
|
+
* Connect to default in-memory configuration:
|
|
108
|
+
* `(connect)`
|
|
109
|
+
*
|
|
110
|
+
* Connect to a database with persistent store:
|
|
111
|
+
* `(connect {:store {:backend :file :path "/tmp/example"}})`
|
|
112
|
+
*/
|
|
113
|
+
export function connect(config?: DatabaseConfig): Promise<Connection>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Creates a database via configuration map. For more information on the configuration refer to the [docs](https://github.com/replikativ/datahike/blob/master/doc/config.md).
|
|
117
|
+
*
|
|
118
|
+
* The configuration is a hash-map with keys: `:store`, `:initial-tx`, `:keep-history?`, `:schema-flexibility`, `:index`
|
|
119
|
+
*
|
|
120
|
+
* - `:store` defines the backend configuration as hash-map with mandatory key: `:backend` and store dependent keys.
|
|
121
|
+
* Per default Datahike ships with `:memory` and `:file` backend.
|
|
122
|
+
* - `:initial-tx` defines the first transaction into the database, often setting default data like the schema.
|
|
123
|
+
* - `:keep-history?` is a boolean that toggles whether Datahike keeps historical data.
|
|
124
|
+
* - `:schema-flexibility` can be set to either `:read` or `:write` setting the validation method for the data.
|
|
125
|
+
* - `:read` validates the data when your read data from the database, `:write` validates the data when you transact new data.
|
|
126
|
+
* - `:index` defines the data type of the index. Available are `:datahike.index/hitchhiker-tree`, `:datahike.index/persistent-set` (only available with in-memory storage)
|
|
127
|
+
* - `:name` defines your database name optionally, if not set, a random name is created
|
|
128
|
+
* - `:writer` optionally configures a writer as a hash map. If not set, the default local writer is used.
|
|
129
|
+
*
|
|
130
|
+
* Default configuration has in-memory store, keeps history with write schema flexibility, and has no initial transaction:
|
|
131
|
+
* `{:store {:backend :memory :id "default"} :keep-history? true :schema-flexibility :write}`
|
|
132
|
+
*
|
|
133
|
+
* Usage:
|
|
134
|
+
*
|
|
135
|
+
* ;; create an empty database:
|
|
136
|
+
* (create-database {:store {:backend :memory :id "example"} :name "my-favourite-database"})
|
|
137
|
+
*
|
|
138
|
+
* ;; Datahike has a strict schema validation (schema-flexibility `:write`) policy by default, that only allows transaction of data that has been pre-defined by a schema.
|
|
139
|
+
* ;; You may influence this behaviour using the `:schema-flexibility` attribute:
|
|
140
|
+
* (create-database {:store {:backend :memory :id "example"} :schema-flexibility :read})
|
|
141
|
+
*
|
|
142
|
+
* ;; By writing historical data in a separate index, datahike has the capability of querying data from any point in time.
|
|
143
|
+
* ;; You may control this feature using the `:keep-history?` attribute:
|
|
144
|
+
* (create-database {:store {:backend :memory :id "example"} :keep-history? false})
|
|
145
|
+
*
|
|
146
|
+
* ;; Initial data after creation may be added using the `:initial-tx` attribute, which in this example adds a schema:
|
|
147
|
+
* (create-database {:store {:backend :memory :id "example"} :initial-tx [{:db/ident :name :db/valueType :db.type/string :db.cardinality/one}]})
|
|
148
|
+
*/
|
|
149
|
+
export function createDatabase(config?: DatabaseConfig): Promise<any>;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Checks if a database exists via configuration map.
|
|
153
|
+
* Usage:
|
|
154
|
+
*
|
|
155
|
+
* (database-exists? {:store {:backend :memory :id "example"}})
|
|
156
|
+
*/
|
|
157
|
+
export function databaseExists(config?: DatabaseConfig): Promise<boolean>;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Index lookup. Returns a sequence of datoms (lazy iterator over actual DB index) which components
|
|
161
|
+
* (e, a, v) match passed arguments. Datoms are sorted in index sort order. Possible `index` values
|
|
162
|
+
* are: `:eavt`, `:aevt`, `:avet`.
|
|
163
|
+
*
|
|
164
|
+
* Accepts db and a map as arguments with the keys `:index` and `:components` provided within the
|
|
165
|
+
* map, or the arguments provided separately.
|
|
166
|
+
*
|
|
167
|
+
*
|
|
168
|
+
* Usage:
|
|
169
|
+
*
|
|
170
|
+
* Set up your database. Beware that for the `:avet` index the index needs to be set to true for
|
|
171
|
+
* the attribute `:likes`.
|
|
172
|
+
*
|
|
173
|
+
* (d/transact db [{:db/ident :name
|
|
174
|
+
* :db/type :db.type/string
|
|
175
|
+
* :db/cardinality :db.cardinality/one}
|
|
176
|
+
* {:db/ident :likes
|
|
177
|
+
* :db/type :db.type/string
|
|
178
|
+
* :db/index true
|
|
179
|
+
* :db/cardinality :db.cardinality/many}
|
|
180
|
+
* {:db/ident :friends
|
|
181
|
+
* :db/type :db.type/ref
|
|
182
|
+
* :db/cardinality :db.cardinality/many}]
|
|
183
|
+
*
|
|
184
|
+
* (d/transact db [{:db/id 4 :name "Ivan"
|
|
185
|
+
* {:db/id 4 :likes "fries"
|
|
186
|
+
* {:db/id 4 :likes "pizza"}
|
|
187
|
+
* {:db/id 4 :friends 5}])
|
|
188
|
+
*
|
|
189
|
+
* (d/transact db [{:db/id 5 :name "Oleg"}
|
|
190
|
+
* {:db/id 5 :likes "candy"}
|
|
191
|
+
* {:db/id 5 :likes "pie"}
|
|
192
|
+
* {:db/id 5 :likes "pizza"}])
|
|
193
|
+
*
|
|
194
|
+
* Find all datoms for entity id == 1 (any attrs and values) sort by attribute, then value
|
|
195
|
+
*
|
|
196
|
+
* (datoms @db {:index :eavt
|
|
197
|
+
* :components [1]}) ; => (#datahike/Datom [1 :friends 2]
|
|
198
|
+
* ; #datahike/Datom [1 :likes "fries"]
|
|
199
|
+
* ; #datahike/Datom [1 :likes "pizza"]
|
|
200
|
+
* ; #datahike/Datom [1 :name "Ivan"])
|
|
201
|
+
*
|
|
202
|
+
* Find all datoms for entity id == 1 and attribute == :likes (any values) sorted by value
|
|
203
|
+
*
|
|
204
|
+
* (datoms @db {:index :eavt
|
|
205
|
+
* :components [1 :likes]}) ; => (#datahike/Datom [1 :likes "fries"]
|
|
206
|
+
* ; #datahike/Datom [1 :likes "pizza"])
|
|
207
|
+
*
|
|
208
|
+
* Find all datoms for entity id == 1, attribute == :likes and value == "pizza"
|
|
209
|
+
*
|
|
210
|
+
* (datoms @db {:index :eavt
|
|
211
|
+
* :components [1 :likes "pizza"]}) ; => (#datahike/Datom [1 :likes "pizza"])
|
|
212
|
+
*
|
|
213
|
+
* Find all datoms for attribute == :likes (any entity ids and values) sorted by entity id, then value
|
|
214
|
+
*
|
|
215
|
+
* (datoms @db {:index :aevt
|
|
216
|
+
* :components [:likes]}) ; => (#datahike/Datom [1 :likes "fries"]
|
|
217
|
+
* ; #datahike/Datom [1 :likes "pizza"]
|
|
218
|
+
* ; #datahike/Datom [2 :likes "candy"]
|
|
219
|
+
* ; #datahike/Datom [2 :likes "pie"]
|
|
220
|
+
* ; #datahike/Datom [2 :likes "pizza"])
|
|
221
|
+
*
|
|
222
|
+
* Find all datoms that have attribute == `:likes` and value == `"pizza"` (any entity id)
|
|
223
|
+
* `:likes` must be a unique attr, reference or marked as `:db/index true`
|
|
224
|
+
*
|
|
225
|
+
* (datoms @db {:index :avet
|
|
226
|
+
* :components [:likes "pizza"]}) ; => (#datahike/Datom [1 :likes "pizza"]
|
|
227
|
+
* ; #datahike/Datom [2 :likes "pizza"])
|
|
228
|
+
*
|
|
229
|
+
* Find all datoms sorted by entity id, then attribute, then value
|
|
230
|
+
*
|
|
231
|
+
* (datoms @db {:index :eavt}) ; => (...)
|
|
232
|
+
*
|
|
233
|
+
*
|
|
234
|
+
* Useful patterns:
|
|
235
|
+
*
|
|
236
|
+
* Get all values of :db.cardinality/many attribute
|
|
237
|
+
*
|
|
238
|
+
* (->> (datoms @db {:index :eavt
|
|
239
|
+
* :components [eid attr]})
|
|
240
|
+
* (map :v))
|
|
241
|
+
*
|
|
242
|
+
* Lookup entity ids by attribute value
|
|
243
|
+
*
|
|
244
|
+
* (->> (datoms @db {:index :avet
|
|
245
|
+
* :components [attr value]})
|
|
246
|
+
* (map :e))
|
|
247
|
+
*
|
|
248
|
+
* Find all entities with a specific attribute
|
|
249
|
+
*
|
|
250
|
+
* (->> (datoms @db {:index :aevt
|
|
251
|
+
* :components [attr]})
|
|
252
|
+
* (map :e))
|
|
253
|
+
*
|
|
254
|
+
* Find “singleton” entity by its attr
|
|
255
|
+
*
|
|
256
|
+
* (->> (datoms @db {:index :aevt
|
|
257
|
+
* :components [attr]})
|
|
258
|
+
* first
|
|
259
|
+
* :e)
|
|
260
|
+
*
|
|
261
|
+
* Find N entities with lowest attr value (e.g. 10 earliest posts)
|
|
262
|
+
*
|
|
263
|
+
* (->> (datoms @db {:index :avet
|
|
264
|
+
* :components [attr]})
|
|
265
|
+
* (take N))
|
|
266
|
+
*
|
|
267
|
+
* Find N entities with highest attr value (e.g. 10 latest posts)
|
|
268
|
+
*
|
|
269
|
+
* (->> (datoms @db {:index :avet
|
|
270
|
+
* :components [attr]})
|
|
271
|
+
* (reverse)
|
|
272
|
+
* (take N))
|
|
273
|
+
*
|
|
274
|
+
*
|
|
275
|
+
* Gotchas:
|
|
276
|
+
*
|
|
277
|
+
* - Index lookup is usually more efficient than doing a query with a single clause.
|
|
278
|
+
* - Resulting iterator is calculated in constant time and small constant memory overhead.
|
|
279
|
+
* - Iterator supports efficient `first`, `next`, `reverse`, `seq` and is itself a sequence.
|
|
280
|
+
* - Will not return datoms that are not part of the index (e.g. attributes with no `:db/index` in schema when querying `:avet` index).
|
|
281
|
+
* - `:eavt` and `:aevt` contain all datoms.
|
|
282
|
+
* - `:avet` only contains datoms for references, `:db/unique` and `:db/index` attributes.
|
|
283
|
+
*/
|
|
284
|
+
export function datoms(db?: Database, args?: { index: string, components?: any[] }): Promise<any>;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Returns the underlying immutable database value from a connection.
|
|
288
|
+
*
|
|
289
|
+
* Exists for Datomic API compatibility. Prefer using `@conn` directly if possible.
|
|
290
|
+
*/
|
|
291
|
+
export function db(conn?: Connection): Promise<Database>;
|
|
292
|
+
|
|
293
|
+
/** Applies transaction to an immutable db value, returning new immutable db value. Same as `(:db-after (with db tx-data))`. */
|
|
294
|
+
export function dbWith(db?: Database, txData?: Transaction[]): Promise<Database>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Deletes a database given via configuration map. Storage configuration `:store` is mandatory.
|
|
298
|
+
* For more information refer to the [docs](https://github.com/replikativ/datahike/blob/master/doc/config.md)
|
|
299
|
+
*/
|
|
300
|
+
export function deleteDatabase(config?: DatabaseConfig): Promise<any>;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Retrieves an entity by its id from database. Entities are lazy map-like structures to navigate Datahike database content.
|
|
304
|
+
*
|
|
305
|
+
* For `eid` pass entity id or lookup attr:
|
|
306
|
+
*
|
|
307
|
+
* (entity db 1)
|
|
308
|
+
* (entity db [:unique-attr :value])
|
|
309
|
+
*
|
|
310
|
+
* If entity does not exist, `nil` is returned:
|
|
311
|
+
*
|
|
312
|
+
* (entity db -1) ; => nil
|
|
313
|
+
*
|
|
314
|
+
* Creating an entity by id is very cheap, almost no-op, as attr access is on-demand:
|
|
315
|
+
*
|
|
316
|
+
* (entity db 1) ; => {:db/id 1}
|
|
317
|
+
*
|
|
318
|
+
* Entity attributes can be lazily accessed through key lookups:
|
|
319
|
+
*
|
|
320
|
+
* (:attr (entity db 1)) ; => :value
|
|
321
|
+
* (get (entity db 1) :attr) ; => :value
|
|
322
|
+
*
|
|
323
|
+
* Cardinality many attributes are returned sequences:
|
|
324
|
+
*
|
|
325
|
+
* (:attrs (entity db 1)) ; => [:v1 :v2 :v3]
|
|
326
|
+
*
|
|
327
|
+
* Reference attributes are returned as another entities:
|
|
328
|
+
*
|
|
329
|
+
* (:ref (entity db 1)) ; => {:db/id 2}
|
|
330
|
+
* (:ns/ref (entity db 1)) ; => {:db/id 2}
|
|
331
|
+
*
|
|
332
|
+
* References can be walked backwards by prepending `_` to name part of an attribute:
|
|
333
|
+
*
|
|
334
|
+
* (:_ref (entity db 2)) ; => [{:db/id 1}]
|
|
335
|
+
* (:ns/_ref (entity db 2)) ; => [{:db/id 1}]
|
|
336
|
+
*
|
|
337
|
+
* Reverse reference lookup returns sequence of entities unless attribute is marked as `:db/component`:
|
|
338
|
+
*
|
|
339
|
+
* (:_component-ref (entity db 2)) ; => {:db/id 1}
|
|
340
|
+
*
|
|
341
|
+
* Entity gotchas:
|
|
342
|
+
*
|
|
343
|
+
* - Entities print as map, but are not exactly maps (they have compatible get interface though).
|
|
344
|
+
* - Entities are effectively immutable “views” into a particular version of a database.
|
|
345
|
+
* - Entities retain reference to the whole database.
|
|
346
|
+
* - You can't change database through entities, only read.
|
|
347
|
+
* - Creating an entity by id is very cheap, almost no-op (attributes are looked up on demand).
|
|
348
|
+
* - Comparing entities just compares their ids. Be careful when comparing entities taken from different dbs or from different versions of the same db.
|
|
349
|
+
* - Accessed entity attributes are cached on entity itself (except backward references).
|
|
350
|
+
* - When printing, only cached attributes (the ones you have accessed before) are printed. See [[touch]].
|
|
351
|
+
*/
|
|
352
|
+
export function entity(db?: Database, eid?: any): Promise<any>;
|
|
353
|
+
|
|
354
|
+
/** Returns a db that entity was created from. */
|
|
355
|
+
export function entityDb(entity?: any): Promise<Database>;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Returns a view over database that has same interface but only includes datoms for which the `(pred db datom)` is true. Can be applied multiple times.
|
|
359
|
+
*
|
|
360
|
+
* Filtered DB gotchas:
|
|
361
|
+
*
|
|
362
|
+
* - All operations on filtered database are proxied to original DB, then filter pred is applied.
|
|
363
|
+
* - Not cached. You pay filter penalty every time.
|
|
364
|
+
* - Supports entities, pull, queries, index access.
|
|
365
|
+
* - Does not support hashing of DB.
|
|
366
|
+
* - Does not support [[with]] and [[db-with]].
|
|
367
|
+
*/
|
|
368
|
+
export function filter(db?: Database, pred?: any): Promise<any>;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Invokes garbage collection on the store of connection by whitelisting currently known branches.
|
|
372
|
+
* All db snapshots on these branches before remove-before date will also be
|
|
373
|
+
* erased (defaults to beginning of time [no erasure]). The branch heads will
|
|
374
|
+
* always be retained. Return the set of removed blobs from the store.
|
|
375
|
+
*/
|
|
376
|
+
export function gcStorage(conn?: Connection, removeBefore?: any): Promise<any>;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Returns the full historical state of the database you may interact with.
|
|
380
|
+
*
|
|
381
|
+
*
|
|
382
|
+
* (transact conn {:tx-data [{:db/ident :name
|
|
383
|
+
* :db/valueType :db.type/string
|
|
384
|
+
* :db/unique :db.unique/identity
|
|
385
|
+
* :db/index true
|
|
386
|
+
* :db/cardinality :db.cardinality/one}
|
|
387
|
+
* {:db/ident :age
|
|
388
|
+
* :db/valueType :db.type/long
|
|
389
|
+
* :db/cardinality :db.cardinality/one}]})
|
|
390
|
+
*
|
|
391
|
+
* (transact conn {:tx-data [{:name "Alice" :age 25} {:name "Bob" :age 30}]})
|
|
392
|
+
*
|
|
393
|
+
* (q {:query '[:find ?n ?a :where [?e :name ?n] [?e :age ?a]]
|
|
394
|
+
* :args [(history @conn)]}) ; => #{["Alice" 25] ["Bob" 30]}
|
|
395
|
+
*
|
|
396
|
+
* (transact conn {:tx-data [{:db/id [:name "Alice"] :age 35}]})
|
|
397
|
+
*
|
|
398
|
+
* (q {:query '[:find ?n ?a :where [?e :name ?n] [?e :age ?a]]
|
|
399
|
+
* :args [@conn]}) ; => #{["Alice" 35] ["Bob" 30]}
|
|
400
|
+
*
|
|
401
|
+
* (q {:query '[:find ?n ?a :where [?e :name ?n] [?e :age ?a]]
|
|
402
|
+
* :args [(history @conn)]}) ; => #{["Alice" 25] ["Bob" 30]}
|
|
403
|
+
*/
|
|
404
|
+
export function history(db?: Database): Promise<Array<any>>;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Returns part of `:avet` index between `[_ attr start]` and `[_ attr end]` in AVET sort order.
|
|
408
|
+
*
|
|
409
|
+
* Same properties as [[datoms]].
|
|
410
|
+
*
|
|
411
|
+
* `attr` must be a reference, unique attribute or marked as `:db/index true`.
|
|
412
|
+
*
|
|
413
|
+
* Usage:
|
|
414
|
+
*
|
|
415
|
+
*
|
|
416
|
+
* (transact db {:tx-data [{:db/ident :name
|
|
417
|
+
* :db/type :db.type/string
|
|
418
|
+
* :db/cardinality :db.cardinality/one}
|
|
419
|
+
* {:db/ident :likes
|
|
420
|
+
* :db/index true
|
|
421
|
+
* :db/type :db.type/string
|
|
422
|
+
* :db/cardinality :db.cardinality/many}
|
|
423
|
+
* {:db/ident :age
|
|
424
|
+
* :db/unique :db.unique/identity
|
|
425
|
+
* :db/type :db.type/ref
|
|
426
|
+
* :db/cardinality :db.cardinality/many}]})
|
|
427
|
+
*
|
|
428
|
+
* (transact db {:tx-data [{:name "Ivan"}
|
|
429
|
+
* {:age 19}
|
|
430
|
+
* {:likes "fries"}
|
|
431
|
+
* {:likes "pizza"}
|
|
432
|
+
* {:likes "candy"}
|
|
433
|
+
* {:likes "pie"}
|
|
434
|
+
* {:likes "pizza"}]})
|
|
435
|
+
*
|
|
436
|
+
* (index-range db {:attrid :likes
|
|
437
|
+
* :start "a"
|
|
438
|
+
* :end "zzzzzzzzz"}) ; => '(#datahike/Datom [2 :likes "candy"]
|
|
439
|
+
* ; #datahike/Datom [1 :likes "fries"]
|
|
440
|
+
* ; #datahike/Datom [2 :likes "pie"]
|
|
441
|
+
* ; #datahike/Datom [1 :likes "pizza"]
|
|
442
|
+
* ; #datahike/Datom [2 :likes "pizza"])
|
|
443
|
+
*
|
|
444
|
+
* (index-range db {:attrid :likes
|
|
445
|
+
* :start "egg"
|
|
446
|
+
* :end "pineapple"}) ; => '(#datahike/Datom [1 :likes "fries"]
|
|
447
|
+
* ; #datahike/Datom [2 :likes "pie"])
|
|
448
|
+
*
|
|
449
|
+
* Useful patterns:
|
|
450
|
+
*
|
|
451
|
+
* ; find all entities with age in a specific range (inclusive)
|
|
452
|
+
* (->> (index-range db {:attrid :age :start 18 :end 60}) (map :e))
|
|
453
|
+
*/
|
|
454
|
+
export function indexRange(db?: Database, args?: { attrid: string, start: any, end: any }): Promise<Datom[]>;
|
|
455
|
+
|
|
456
|
+
/** Returns `true` if this database was filtered using [[filter]], `false` otherwise. */
|
|
457
|
+
export function isFiltered(db?: Database): Promise<boolean>;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Listen for changes on the given connection. Whenever a transaction is applied to the database via
|
|
461
|
+
* [[transact]], the callback is called with the transaction report. `key` is any opaque unique value.
|
|
462
|
+
*
|
|
463
|
+
* Idempotent. Calling [[listen]] with the same twice will override old callback with the new value.
|
|
464
|
+
*
|
|
465
|
+
* Returns the key under which this listener is registered. See also [[unlisten]].
|
|
466
|
+
*/
|
|
467
|
+
export function listen(conn?: Connection, callback?: Function): Promise<any>;
|
|
468
|
+
|
|
469
|
+
/** Load entities directly */
|
|
470
|
+
export function loadEntities(conn?: Connection, txs?: Transaction[]): Promise<any>;
|
|
471
|
+
|
|
472
|
+
/** Returns database metrics. */
|
|
473
|
+
export function metrics(db?: Database): Promise<Metrics>;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Fetches data from database using recursive declarative description. See [docs.datomic.com/on-prem/pull.html](https://docs.datomic.com/on-prem/pull.html).
|
|
477
|
+
*
|
|
478
|
+
* Unlike [[entity]], returns plain Clojure map (not lazy).
|
|
479
|
+
*
|
|
480
|
+
* Usage:
|
|
481
|
+
*
|
|
482
|
+
* (pull db [:db/id, :name, :likes, {:friends [:db/id :name]}] 1) ; => {:db/id 1,
|
|
483
|
+
* :name "Ivan"
|
|
484
|
+
* :likes [:pizza]
|
|
485
|
+
* :friends [{:db/id 2, :name "Oleg"}]}
|
|
486
|
+
*
|
|
487
|
+
* The arity-2 version takes :selector and :eid in arg-map.
|
|
488
|
+
*/
|
|
489
|
+
export function pull(db?: Database, opts?: { selector: any[], eid: number | string }): Promise<any>;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Same as [[pull]], but accepts sequence of ids and returns sequence of maps.
|
|
493
|
+
*
|
|
494
|
+
* Usage:
|
|
495
|
+
*
|
|
496
|
+
* (pull-many db [:db/id :name] [1 2]) ; => [{:db/id 1, :name "Ivan"}
|
|
497
|
+
* {:db/id 2, :name "Oleg"}]
|
|
498
|
+
*/
|
|
499
|
+
export function pullMany(db?: Database, opts?: { selector: any[], eid: number | string }): Promise<Array<object>>;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Executes a datalog query. See [docs.datomic.com/on-prem/query.html](https://docs.datomic.com/on-prem/query.html).
|
|
503
|
+
*
|
|
504
|
+
* Usage:
|
|
505
|
+
*
|
|
506
|
+
* Query as parameter with additional args:
|
|
507
|
+
*
|
|
508
|
+
* (q '[:find ?value
|
|
509
|
+
* :where [_ :likes ?value]]
|
|
510
|
+
* #{[1 :likes "fries"]
|
|
511
|
+
* [2 :likes "candy"]
|
|
512
|
+
* [3 :likes "pie"]
|
|
513
|
+
* [4 :likes "pizza"]}) ; => #{["fries"] ["candy"] ["pie"] ["pizza"]}
|
|
514
|
+
*
|
|
515
|
+
* Or query passed in arg-map:
|
|
516
|
+
*
|
|
517
|
+
* (q {:query '[:find ?value
|
|
518
|
+
* :where [_ :likes ?value]]
|
|
519
|
+
* :offset 2
|
|
520
|
+
* :limit 1
|
|
521
|
+
* :args [#{[1 :likes "fries"]
|
|
522
|
+
* [2 :likes "candy"]
|
|
523
|
+
* [3 :likes "pie"]
|
|
524
|
+
* [4 :likes "pizza"]}]}) ; => #{["fries"] ["candy"] ["pie"] ["pizza"]}
|
|
525
|
+
*
|
|
526
|
+
* Or query passed as map of vectors:
|
|
527
|
+
*
|
|
528
|
+
* (q '{:find [?value] :where [[_ :likes ?value]]}
|
|
529
|
+
* #{[1 :likes "fries"]
|
|
530
|
+
* [2 :likes "candy"]
|
|
531
|
+
* [3 :likes "pie"]
|
|
532
|
+
* [4 :likes "pizza"]}) ; => #{["fries"] ["candy"] ["pie"] ["pizza"]}
|
|
533
|
+
*
|
|
534
|
+
* Or query passed as string:
|
|
535
|
+
*
|
|
536
|
+
* (q {:query "[:find ?value :where [_ :likes ?value]]"
|
|
537
|
+
* :args [#{[1 :likes "fries"]
|
|
538
|
+
* [2 :likes "candy"]
|
|
539
|
+
* [3 :likes "pie"]
|
|
540
|
+
* [4 :likes "pizza"]}]})
|
|
541
|
+
*
|
|
542
|
+
* Query passed as map needs vectors as values. Query can not be passed as list. The 1-arity function takes a map with the arguments :query and :args and optionally the additional keys :offset and :limit.
|
|
543
|
+
*/
|
|
544
|
+
export function q(map?: { query: string | any[], args?: any[], limit?: number, offset?: number }): Promise<any>;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Executes a datalog query and returns the result as well as some execution details.
|
|
548
|
+
* Uses the same arguments as q does.
|
|
549
|
+
*/
|
|
550
|
+
export function queryStats(map?: { query: string | any[], args?: any[], limit?: number, offset?: number }): Promise<object>;
|
|
551
|
+
|
|
552
|
+
/** Releases a database connection. You need to release a connection as many times as you connected to it for it to be completely released. Set release-all? to true to force its release. */
|
|
553
|
+
export function release(conn?: Connection): Promise<null>;
|
|
554
|
+
|
|
555
|
+
/** Returns current reverse schema definition. */
|
|
556
|
+
export function reverseSchema(db?: Database): Promise<object>;
|
|
557
|
+
|
|
558
|
+
/** Returns current schema definition. */
|
|
559
|
+
export function schema(db?: Database): Promise<Schema>;
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Similar to [[datoms]], but will return datoms starting from specified components and including rest of the database until the end of the index.
|
|
563
|
+
*
|
|
564
|
+
* If no datom matches passed arguments exactly, iterator will start from first datom that could be considered “greater” in index order.
|
|
565
|
+
*
|
|
566
|
+
* Usage:
|
|
567
|
+
*
|
|
568
|
+
* (seek-datoms @db {:index :eavt
|
|
569
|
+
* :components [1]}) ; => (#datahike/Datom [1 :friends 2]
|
|
570
|
+
* ; #datahike/Datom [1 :likes "fries"]
|
|
571
|
+
* ; #datahike/Datom [1 :likes "pizza"]
|
|
572
|
+
* ; #datahike/Datom [1 :name "Ivan"]
|
|
573
|
+
* ; #datahike/Datom [2 :likes "candy"]
|
|
574
|
+
* ; #datahike/Datom [2 :likes "pie"]
|
|
575
|
+
* ; #datahike/Datom [2 :likes "pizza"])
|
|
576
|
+
*
|
|
577
|
+
* (seek-datoms @db {:index :eavt
|
|
578
|
+
* :components [1 :name]}) ; => (#datahike/Datom [1 :name "Ivan"]
|
|
579
|
+
* ; #datahike/Datom [2 :likes "candy"]
|
|
580
|
+
* ; #datahike/Datom [2 :likes "pie"]
|
|
581
|
+
* ; #datahike/Datom [2 :likes "pizza"])
|
|
582
|
+
*
|
|
583
|
+
* (seek-datoms @db {:index :eavt
|
|
584
|
+
* :components [2]}) ; => (#datahike/Datom [2 :likes "candy"]
|
|
585
|
+
* ; #datahike/Datom [2 :likes "pie"]
|
|
586
|
+
* ; #datahike/Datom [2 :likes "pizza"])
|
|
587
|
+
*
|
|
588
|
+
* No datom `[2 :likes "fish"]`, so starts with one immediately following such in index
|
|
589
|
+
*
|
|
590
|
+
* (seek-datoms @db {:index :eavt
|
|
591
|
+
* :components [2 :likes "fish"]}) ; => (#datahike/Datom [2 :likes "pie"]
|
|
592
|
+
* ; #datahike/Datom [2 :likes "pizza"])
|
|
593
|
+
*/
|
|
594
|
+
export function seekDatoms(db?: Database, args?: { index: string, components?: any[] }): Promise<any>;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Returns the database state since a given point in time (you may use either java.util.Date or a transaction ID as long).
|
|
598
|
+
* Be aware: the database contains only the datoms that were added since the date.
|
|
599
|
+
*
|
|
600
|
+
*
|
|
601
|
+
* (transact conn {:tx-data [{:db/ident :name
|
|
602
|
+
* :db/valueType :db.type/string
|
|
603
|
+
* :db/unique :db.unique/identity
|
|
604
|
+
* :db/index true
|
|
605
|
+
* :db/cardinality :db.cardinality/one}
|
|
606
|
+
* {:db/ident :age
|
|
607
|
+
* :db/valueType :db.type/long
|
|
608
|
+
* :db/cardinality :db.cardinality/one}]})
|
|
609
|
+
*
|
|
610
|
+
* (transact conn {:tx-data [{:name "Alice" :age 25} {:name "Bob" :age 30}]})
|
|
611
|
+
*
|
|
612
|
+
* (def date (java.util.Date.))
|
|
613
|
+
*
|
|
614
|
+
* (transact conn [{:db/id [:name "Alice"] :age 30}])
|
|
615
|
+
*
|
|
616
|
+
* (q '[:find ?n ?a
|
|
617
|
+
* :in $ $since
|
|
618
|
+
* :where
|
|
619
|
+
* [$ ?e :name ?n]
|
|
620
|
+
* [$since ?e :age ?a]]
|
|
621
|
+
* @conn
|
|
622
|
+
* (since @conn date)) ; => #{["Alice" 30]}
|
|
623
|
+
*
|
|
624
|
+
* (q {:query '[:find ?n ?a :where [?e :name ?n] [?e :age ?a]]
|
|
625
|
+
* :args [@conn]}) ; => #{["Alice" 30] ["Bob" 30]}
|
|
626
|
+
*/
|
|
627
|
+
export function since(db?: Database, timePoint?: any): Promise<Database>;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Allocates and returns a unique temporary id (a negative integer). Ignores `part`. Returns `x` if it is specified.
|
|
631
|
+
*
|
|
632
|
+
* Exists for Datomic API compatibility. Prefer using negative integers directly if possible.
|
|
633
|
+
*/
|
|
634
|
+
export function tempid(): Promise<any>;
|
|
635
|
+
|
|
636
|
+
/** Same as transact, but asynchronously returns a future. */
|
|
637
|
+
export function transact(conn?: Connection, txs?: Transaction[]): Promise<any>;
|
|
638
|
+
|
|
639
|
+
/** Removes registered listener from connection. See also [[listen]]. */
|
|
640
|
+
export function unlisten(conn?: Connection, key?: any): Promise<object>;
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Same as [[transact]]`, but applies to an immutable database value. Returns transaction report (see [[transact]]).
|
|
644
|
+
*
|
|
645
|
+
* Accepts tx-data and tx-meta as a map.
|
|
646
|
+
*
|
|
647
|
+
* (with @conn {:tx-data [[:db/add 1 :name "Ivan"]]}) ; => {:db-before #datahike/DB {:max-tx 536870912 :max-eid 0},
|
|
648
|
+
* ; :db-after #datahike/DB {:max-tx 536870913 :max-eid 1},
|
|
649
|
+
* ; :tx-data [#datahike/Datom [1 :name "Ivan" 536870913]],
|
|
650
|
+
* ; :tempids #:db{:current-tx 536870913},
|
|
651
|
+
* ; :tx-meta nil}
|
|
652
|
+
*
|
|
653
|
+
* (with @conn {:tx-data [[:db/add 1 :name "Ivan"]]
|
|
654
|
+
* :tx-meta {:foo :bar}}) ; => {:db-before #datahike/DB {:max-tx 536870912 :max-eid 0},
|
|
655
|
+
* ; :db-after #datahike/DB {:max-tx 536870913 :max-eid 1},
|
|
656
|
+
* ; :tx-data [#datahike/Datom [1 :name "Ivan" 536870913]],
|
|
657
|
+
* ; :tempids #:db{:current-tx 536870913},
|
|
658
|
+
* ; :tx-meta {:foo :bar}}
|
|
659
|
+
*/
|
|
660
|
+
export function withDb(db?: Database, argmap?: { 'tx-data': Transaction[], 'tx-meta'?: any }): Promise<TransactionReport>;
|