Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

web


web / lib/utils/user-data

lib/utils/user-data

Shared helpers for fetching user-owned collection data.

Both AccountDeletionService and DataExportService need to count and fetch documents owned by a user across multiple collections. This module eliminates the repeated payload.find/count boilerplate.

Functions

countUserDocs()

countUserDocs(payload, collection, userId, options?): Promise<number>

Count documents in a collection that belong to a user.

Parameters

payload

BasePayload

Payload instance

collection

Collection slug to count in

"import-files" | "catalogs" | "data-exports" | "datasets" | "dataset-schemas" | "audit-log" | "import-jobs" | "scheduled-imports" | "events" | "users" | "user-usage" | "media" | "location-cache" | "geocoding-providers" | "pages" | "sites" | "themes" | "layout-templates" | "views" | "schema-detectors" | "payload-kv" | "payload-jobs" | "payload-locked-documents" | "payload-preferences" | "payload-migrations"

userId

number

The user ID to filter by

options?

Optional configuration

userField?

string

Field name that stores the user reference (default: “createdBy”)

extraWhere?

Where[]

Additional where conditions to apply

Returns

Promise<number>

The total number of matching documents


findUserDocs()

findUserDocs<T>(payload, collection, userId, options?): Promise<object[T][]>

Find all documents in a collection that belong to a user.

Returns all matching docs with pagination disabled by default.

Type Parameters

T

T extends "import-files" | "catalogs" | "data-exports" | "datasets" | "dataset-schemas" | "audit-log" | "import-jobs" | "scheduled-imports" | "events" | "users" | "user-usage" | "media" | "location-cache" | "geocoding-providers" | "pages" | "sites" | "themes" | "layout-templates" | "views" | "schema-detectors" | "payload-kv" | "payload-jobs" | "payload-locked-documents" | "payload-preferences" | "payload-migrations"

Parameters

payload

BasePayload

Payload instance

collection

T

Collection slug to search in

userId

number

The user ID to filter by

options?

Optional configuration

userField?

string

Field name that stores the user reference (default: “createdBy”)

extraWhere?

Where[]

Additional where conditions to apply

limit?

number

Maximum number of documents to return (default: no limit)

Returns

Promise<object[T][]>

Array of matching documents

Last updated on