|
120 | 120 | [this k schema opts] |
121 | 121 | (p/let [k' (api-block/sanitize-user-property-name k) |
122 | 122 | property-ident (api-block/get-db-ident-from-property-name k' this) |
123 | | - property (db/entity property-ident)] |
124 | | - (if property |
125 | | - property |
126 | | - (p/let [_ (api-block/ensure-property-upsert-control this property-ident k') |
127 | | - schema (or (some-> schema bean/->clj |
128 | | - (update-keys #(if (contains? #{:hide :public} %) |
129 | | - (keyword (str (name %) "?")) %))) |
130 | | - {}) |
131 | | - _ (when (:type schema) |
132 | | - (schema-type-check! (keyword (:type schema)))) |
133 | | - schema (cond-> schema |
134 | | - (string? (:cardinality schema)) |
135 | | - (-> (assoc :db/cardinality (->cardinality (:cardinality schema))) |
136 | | - (dissoc :cardinality)) |
137 | | - |
138 | | - (string? (:type schema)) |
139 | | - (-> (assoc :logseq.property/type (keyword (:type schema))) |
140 | | - (dissoc :type))) |
141 | | - p (db-property-handler/upsert-property! property-ident schema |
142 | | - (assoc opts :property-name k'))] |
143 | | - (db/entity (:db/id p)))))) |
| 123 | + _ (api-block/ensure-property-upsert-control this property-ident k') |
| 124 | + schema (or (some-> schema |
| 125 | + (update-keys #(if (contains? #{:hide :public} %) |
| 126 | + (keyword (str (name %) "?")) %))) |
| 127 | + {}) |
| 128 | + _ (when (:type schema) |
| 129 | + (schema-type-check! (keyword (:type schema)))) |
| 130 | + schema (cond-> schema |
| 131 | + (string? (:cardinality schema)) |
| 132 | + (-> (assoc :db/cardinality (->cardinality (:cardinality schema))) |
| 133 | + (dissoc :cardinality)) |
| 134 | + |
| 135 | + (string? (:type schema)) |
| 136 | + (-> (assoc :logseq.property/type (keyword (:type schema))) |
| 137 | + (dissoc :type))) |
| 138 | + p (db-property-handler/upsert-property! property-ident schema |
| 139 | + (assoc opts :property-name k'))] |
| 140 | + (db/entity (:db/id p)))) |
144 | 141 |
|
145 | 142 | (defn upsert-property |
146 | 143 | "schema: |
|
0 commit comments