The Collections class acts as a manager for all collection operations within a specific Stream client and token. It provides methods to interact with entire collections (like add, get, update, delete, and batch operations like upsertMany).
When you retrieve a specific item using Collections.get(), it returns a CollectionEntry object. A CollectionEntry is a specialized instance representing a single item within a collection. It allows you to perform operations directly on that specific item (e.g., entry.update(), entry.delete()) without needing to pass the collection name and ID again. This pattern provides a more object-oriented way to manage individual data entries.
// 1. Use Collections to get a specific entry
const entry = await collections.get("food", "cheese101");
// 2. Use the entry directly to perform actions
await entry.update({ name: "new cheese burger" });
await entry.delete();