collections module organizes the logged-in user’s saved content. Every user has a single root collection, under which they can nest sub-collections and into which they can save entities.
A collection’s
entityCount counts the entities the user can see in it, by the same rule as the totalItems of its entities list, so the two always match: entities that are deleted, removed by moderation, back in drafts, or in a space they can’t read (see who can read content) aren’t counted or listed, though they stay saved. Saving an entity in a space they can’t read fails with 404 entity/not-found. See Collection → entityCount.fetchRootCollection
Fetches the logged-in user’s root collection.Promise<Collection>
fetchSubCollections
Fetches the immediate sub-collections of a collection.Promise<{ data: Collection[] }> — the direct children, oldest first, each with its entityCount.
createNewCollection
Creates a sub-collection under a parent collection.Promise<Collection>
fetchCollectionEntities
Fetches the entities within a collection, paginated.The number of entities to return per page: a whole number from
1 to 100. Defaults to 20. A larger value is rejected with 400 collection/invalid-query, never lowered to 100.Sort order:
"createdAt" (creation date), "addedAt" (when saved), "top" (reaction count), or "hot" (engagement score).Which reaction
top ranks by: "upvote", "downvote", "like", "love", "wow", "sad", "angry", or "funny". Defaults to "upvote". Only valid with sortBy: "top" — the server rejects it with any other sort.Associations to populate:
"user", "space", "topComments", "files", "grants" (a single value or an array). "saved" isn’t accepted — every returned entity is in this collection.With
include containing "topComments": how many top comments per entity. Server default 1, maximum 5. Rejected (400) without "topComments" in include.With
include containing "topComments": the reaction whose raw count ranks the top comments. Server default "upvote". Rejected (400) without "topComments" in include.Promise<PaginatedResponse<Entity>>
addEntityToCollection
Adds an entity to a collection.Promise<{ id: string; name: string; entityCount: number }>: the collection’s summary after the save. The same whether the entity was just added or already in the collection, so a repeat save is safe.
removeEntityFromCollection
Removes an entity from a collection.Promise<{ id: string; name: string; entityCount: number }>: the collection’s summary after the removal, whether or not the entity was in it.
updateCollection
Renames a collection.Promise<Collection>
deleteCollection
Deletes a collection and every collection under it, at any depth. The root collection can’t be deleted.Promise<{ deletedCollectionIds: string[] }>: the deleted collection and every collection under it. See Delete Collection.
