datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
emak 2021-05-11T16:11:21.080500Z

Hello I am new to datascript and I explore Athens codebase that uses it. Playing with datascript.core/datoms I get an error with the :avet index: #error {:message "Attribute :block/string should be marked as :db/index true", :data {:error :index-access, :index :avet, :components [:block/string]}} Where should I declare this :db/index true ?

❤️ 2
emak 2021-05-11T16:14:40.080700Z

here is my lookup (d/datoms @dsdb :avet :block/string) I tried to edit the schema here without much success https://github.com/athensresearch/athens/blob/main/src/cljs/athens/db.cljs#L126-L134

emak 2021-05-11T16:17:51.081Z

my new schema looks like this with :block/string added

@@ -131,7 +130,8 @@
    :block/children {:db/cardinality :db.cardinality/many
                     :db/valueType :db.type/ref}
    :block/refs     {:db/cardinality :db.cardinality/many
-                    :db/valueType :db.type/ref}})
+                    :db/valueType :db.type/ref}
+   :block/string   {:db/index true}})

2021-05-11T17:40:09.081400Z

@emilien without looking at the doc's that seems reasonable, are you still getting the error?

emak 2021-05-11T18:24:33.081800Z

yes, but I think it has something to do with the way the db is created on Athens side. Because in the REPL I can see the index when I do (d/empty-db schema) But the index is notthere when I inspect the schema for the datascript db that is defined here https://github.com/athensresearch/athens/blob/main/src/cljs/athens/db.cljs#L137 It must be reset somewhere else. I need to dig more.