Skip to content

js-bao-wss-client


js-bao-wss-client / CollectionsAPI

Interface: CollectionsAPI

Methods

addDocument()

addDocument(collectionId, documentId): Promise<CollectionDocumentInfo>

Add a document to a collection.

Parameters

collectionId

string

The unique identifier of the collection to add the document to

documentId

string

The unique identifier of the document to add

Returns

Promise<CollectionDocumentInfo>


addMember()

addMember(collectionId, params): Promise<CollectionMemberInfo>

Add a member to a collection.

Parameters

collectionId

string

The unique identifier of the collection to add the member to

params

AddCollectionMemberParams

Member details

Returns

Promise<CollectionMemberInfo>


create()

create(params): Promise<CollectionInfo>

Create a new collection.

Parameters

params

CreateCollectionParams

Configuration for the new collection

Returns

Promise<CollectionInfo>


delete()

delete(collectionId): Promise<{ success: boolean; }>

Delete a collection.

Parameters

collectionId

string

The unique identifier of the collection to delete

Returns

Promise<{ success: boolean; }>


get()

get(collectionId): Promise<CollectionInfo>

Get collection info by ID.

Callers must either be an admin/owner of the app, hold a direct _col-reader or _col-writer membership on the collection, or belong to a user-group that has been granted a CollectionGroupPermission of reader or read-write. Otherwise the server returns 404 (to avoid leaking collection existence).

Parameters

collectionId

string

The unique identifier of the collection to retrieve

Returns

Promise<CollectionInfo>


getAccess()

getAccess(collectionId): Promise<CollectionAccessInfo>

Get the current user's access info for a collection.

Parameters

collectionId

string

The unique identifier of the collection to check access for

Returns

Promise<CollectionAccessInfo>


grantGroupPermission()

grantGroupPermission(collectionId, params): Promise<CollectionGroupPermissionInfo>

Grant a group permission to a collection.

Parameters

collectionId

string

The unique identifier of the collection to grant access to

params

GrantCollectionGroupPermissionParams

Permission grant details

Returns

Promise<CollectionGroupPermissionInfo>


list()

list(options?): Promise<PaginatedResult<CollectionInfo>>

List collections the caller is a direct member of (reader or read-write).

This returns only collections the caller has been explicitly added to — it does NOT include collections accessible only via a user-created group that holds a CollectionGroupPermission. Admins see only their own direct memberships too; use listAll() for the full app-wide set.

Each returned item includes a permission field ("reader" or "read-write") reflecting the caller's direct access level.

Parameters

options?

PaginationOptions

Pagination controls

Returns

Promise<PaginatedResult<CollectionInfo>>


listAll()

listAll(options?): Promise<PaginatedResult<CollectionInfo>>

List every collection in the app (admin-only).

Non-admin callers receive a 403. Unlike list(), the returned items do not include a permission field (since the caller may not have direct access to many of them).

Parameters

options?

PaginationOptions

Pagination controls

Returns

Promise<PaginatedResult<CollectionInfo>>


listCollectionsForDocument()

listCollectionsForDocument(documentId, options?): Promise<PaginatedResult<DocumentCollectionInfo>>

List collections that contain a specific document.

For admin/owner callers, returns every collection the document belongs to. For non-admin callers, returns only collections the caller is a direct member of (_col-reader or _col-writer). Access via a user-created group is NOT counted here (consistent with list()).

Parameters

documentId

string

The unique identifier of the document to look up

options?

PaginationOptions

Pagination controls

Returns

Promise<PaginatedResult<DocumentCollectionInfo>>


listDocuments()

listDocuments(collectionId, options?): Promise<PaginatedResult<CollectionDocumentInfo>>

List all documents in a collection.

Parameters

collectionId

string

The unique identifier of the collection whose documents to list

options?

PaginationOptions

Pagination controls

Returns

Promise<PaginatedResult<CollectionDocumentInfo>>


removeDocument()

removeDocument(collectionId, documentId): Promise<{ success: boolean; }>

Remove a document from a collection.

Parameters

collectionId

string

The unique identifier of the collection to remove the document from

documentId

string

The unique identifier of the document to remove

Returns

Promise<{ success: boolean; }>


removeMember()

removeMember(collectionId, userId): Promise<{ success: boolean; }>

Remove a member from a collection.

Parameters

collectionId

string

The unique identifier of the collection to remove the member from

userId

string

The unique identifier of the user to remove

Returns

Promise<{ success: boolean; }>


revokeGroupPermission()

revokeGroupPermission(collectionId, groupType, groupId): Promise<{ success: boolean; }>

Revoke a group's permission from a collection.

Parameters

collectionId

string

The unique identifier of the collection to revoke access from

groupType

string

The kind of group whose permission is being revoked

groupId

string

The unique identifier of the group losing the permission

Returns

Promise<{ success: boolean; }>


update()

update(collectionId, params): Promise<CollectionInfo>

Update a collection's title or description.

Parameters

collectionId

string

The unique identifier of the collection to update

params

UpdateCollectionParams

Fields to update on the collection

Returns

Promise<CollectionInfo>