Skip to content

Commit 4075c0d

Browse files
enhance: allow users to store any metadata on nodes via :map
property and EDN or API property creation
1 parent 894a52f commit 4075c0d

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

deps/db/src/logseq/db/frontend/malli_schema.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@
334334
(concat
335335
[:map
336336
[:db/ident user-property-ident]
337-
[:logseq.property/type (apply vector :enum db-property-type/user-built-in-property-types)]]
337+
[:logseq.property/type (apply vector :enum (into db-property-type/user-allowed-internal-property-types
338+
db-property-type/user-built-in-property-types))]]
338339
property-common-schema-attrs
339340
property-attrs
340341
page-attrs

deps/db/src/logseq/db/frontend/property/type.cljs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
"Valid property types for users in order they appear in the UI"
2121
[:default :number :date :datetime :checkbox :url :node])
2222

23+
(def user-allowed-internal-property-types
24+
"Internal property types that users are allowed to store. These aren't available in the UI
25+
so these would normally be created via EDN or the API."
26+
#{:map})
27+
28+
(assert (set/subset? user-allowed-internal-property-types internal-built-in-property-types))
29+
2330
(def closed-value-property-types
2431
"Valid property :type for closed values"
2532
#{:default :number :url})

deps/db/test/logseq/db/sqlite/export_test.cljs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@
428428
:user.property/node {:logseq.property/type :node
429429
:db/cardinality :db.cardinality/many
430430
:build/property-classes [:user.class/MyClass]}
431-
:user.property/p1 {:logseq.property/type :default}}
431+
:user.property/p1 {:logseq.property/type :default}
432+
:user.property/map {:logseq.property/type :map}}
432433
:classes {:user.class/MyClass {:build/class-properties [:user.property/p1]}}
433434
:pages-and-blocks
434435
[{:page {:block/title "page1"}
@@ -442,7 +443,9 @@
442443
:build/properties {:user.property/node #{[:build/page {:block/title "page object"
443444
:build/tags [:user.class/MyClass]}]
444445
[:block/uuid block-object-uuid]
445-
:logseq.class/Task}}}]}
446+
:logseq.class/Task}}}
447+
{:block/title "map block"
448+
:build/properties {:user.property/map {:foo :bar :num 2}}}]}
446449
{:page {:block/title "Blocks"}
447450
:blocks [{:block/title "myclass object"
448451
:build/tags [:user.class/MyClass]

0 commit comments

Comments
 (0)