Group Metadata
Attach structured custom data to a group for organization and app-specific logic.
备注
Obtain group via getGroupById or getGroupByName on userInstance — see Get Groups.
What This Module Does ?
Update metadata (key-value fields) on a group—room name, labels, or any JSON-serializable app data separate from RainMaker's built-in group fields.
Use this when your UI filters or displays groups using custom attributes not covered by name or description.
Use customData on createGroup in Manage Groups to set metadata at creation time.
Expected outcome: Metadata is stored on the group and returned on subsequent group fetches (when included by the API).
Common Workflows
Update metadata
const group = await userInstance.getGroupById({ groupId: "group_id_123" });
await group.updateMetadata({
room: "kitchen",
floor: 1,
lastUpdated: new Date().toISOString(),
});
Set metadata at creation
await userInstance.createGroup({
name: "Kitchen Devices",
nodeIds: [],
customData: { room: "kitchen", icon: "chef" },
});
Error Handling
try {
await group.updateMetadata(metadata);
} catch (error) {
console.error("Failed to update group metadata:", error);
}
Keep payloads JSON-serializable; avoid circular references.
Best Practices
- Use consistent keys across your app (
room,floor,icon) - Prefer
customDataat create when metadata is known upfront - Do not store secrets in group metadata
Related Resource
- API Reference: