You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/items/metadata.js
+38-8Lines changed: 38 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -111,14 +111,45 @@ function _getSingleItemMetadata (itemName, namespace) {
111
111
* @memberOf items.metadata
112
112
* @param {Item|string} itemOrName {@link Item} or the name of the Item
113
113
* @param {string} [namespace] name of the metadata: if provided, only metadata of this namespace is returned, else all metadata is returned
114
-
* @returns {{ namespace: ItemMetadata }|ItemMetadata|null} all metadata as an object with the namespaces as properties OR metadata of a single namespace or `null` if that namespace doesn't exist; the metadata itself is of type {@link ItemMetadata}
114
+
* @returns {{ namespace: ItemMetadata }|ItemMetadata|null} all metadata as an object with the namespaces as properties OR metadata of a single
115
+
* namespace or `null` if that namespace doesn't exist; the metadata itself is of type {@link ItemMetadata}
* Generally, storing objects in metadata is not the best idea, as they are not necessarily serializable and therefore JSONDB will not be able to store them.
141
+
* Wrt to JavaScript objects specifically, they are passed by reference (as all objects), and that reference becomes invalid if the script that created the
142
+
* object is reloaded, causing various issues failure of related REST API endpoints.
143
+
* */
144
+
console.warn(`Metadata configuration values must be primitive types, not objects. Ignoring configuration for key '${key}' of metadata '${namespace}' for Item '${itemName}'`);
145
+
deleteconfigurationClone[key];
146
+
}
147
+
}
148
+
149
+
constkey=newMetadataKey(namespace,itemName);
150
+
returnnewMetadata(key,value,configurationClone);
151
+
}
152
+
122
153
/**
123
154
* Adds metadata of a single namespace to an Item.
124
155
*
@@ -137,8 +168,7 @@ function getMetadata (itemOrName, namespace) {
Copy file name to clipboardExpand all lines: types/items/metadata.d.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,8 @@ export type Item = {
57
57
* @memberOf items.metadata
58
58
* @param {Item|string} itemOrName {@link Item} or the name of the Item
59
59
* @param {string} [namespace] name of the metadata: if provided, only metadata of this namespace is returned, else all metadata is returned
60
-
* @returns {{ namespace: ItemMetadata }|ItemMetadata|null} all metadata as an object with the namespaces as properties OR metadata of a single namespace or `null` if that namespace doesn't exist; the metadata itself is of type {@link ItemMetadata}
60
+
* @returns {{ namespace: ItemMetadata }|ItemMetadata|null} all metadata as an object with the namespaces as properties OR metadata of a single
61
+
* namespace or `null` if that namespace doesn't exist; the metadata itself is of type {@link ItemMetadata}
0 commit comments