Fork me on GitHub
#datascript
<
2021-05-11
>
emak16:05:21

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 ?

❤️ 7
emak16:05:40

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

emak16:05:51

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}})

Drew Verlee17:05:09

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

emak18:05:33

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.