Skip to content

Commit 3962f1f

Browse files
committed
enhance: get-tag-objects accept block uuid, db/ident or title
1 parent 8efd79e commit 3962f1f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/main/logseq/api/db_based.cljs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,17 @@
175175
sdk-utils/result->js))
176176

177177
(defn get-tag-objects
178-
[class-uuid-or-ident]
179-
(let [eid (if (util/uuid-string? class-uuid-or-ident)
180-
(when-let [id (sdk-utils/uuid-or-throw-error class-uuid-or-ident)]
178+
[class-uuid-or-ident-or-title]
179+
(let [eid (if (util/uuid-string? class-uuid-or-ident-or-title)
180+
(when-let [id (sdk-utils/uuid-or-throw-error class-uuid-or-ident-or-title)]
181181
[:block/uuid id])
182-
(keyword (api-block/sanitize-user-property-name class-uuid-or-ident)))
182+
(let [k (keyword (api-block/sanitize-user-property-name class-uuid-or-ident-or-title))]
183+
(if (qualified-keyword? k)
184+
k
185+
(ldb/get-case-page (db/get-db) class-uuid-or-ident-or-title))))
183186
class (db/entity eid)]
187+
(when-not (ldb/class? class)
188+
(throw (ex-info "Not a tag" {:input class-uuid-or-ident-or-title})))
184189
(if-not class
185190
(throw (ex-info (str "Tag not exists with id: " eid) {}))
186191
(p/let [result (state/<invoke-db-worker :thread-api/get-class-objects

0 commit comments

Comments
 (0)