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

web


web / lib/jobs/utils/bulk-event-insert

lib/jobs/utils/bulk-event-insert

Bulk INSERT utility for event creation during imports.

Uses Drizzle’s typed table API (payload-generated-schema) to insert events directly into PostgreSQL, bypassing Payload hooks for throughput. Also populates the _events_v versions table to keep Payload’s draft/publish system consistent.

Only used by the import pipeline where hooks are redundant (quota and access fields are handled at the job level).

Interfaces

BulkEventData

Shape of a single event to be bulk-inserted.

Maps 1:1 to the output of createEventData plus the denormalized access fields that the import job pre-computes once.

Properties

dataset

dataset: number

ingestJob?

optional ingestJob?: number

originalData

originalData: Record<string, unknown>

uniqueId

uniqueId: string

eventTimestamp

eventTimestamp: string

location?

optional location?: object

latitude

latitude: number

longitude

longitude: number

locationName?

optional locationName?: string | null

coordinateSource

coordinateSource: object

type

type: string

confidence?

optional confidence?: number

normalizedAddress?

optional normalizedAddress?: string

validationStatus

validationStatus: string

transformations?

optional transformations?: unknown

schemaVersionNumber?

optional schemaVersionNumber?: number

contentHash?

optional contentHash?: string

datasetIsPublic?

optional datasetIsPublic?: boolean

catalogOwnerId?

optional catalogOwnerId?: number

Functions

bulkInsertEvents()

bulkInsertEvents(payload, allEvents): Promise<number>

Bulk-insert events into the events and _events_v tables, bypassing Payload hooks.

Splits the input into batches of BATCH_SIZE rows and executes typed Drizzle INSERT statements. This is orders of magnitude faster than calling payload.create() per row.

Parameters

payload

BasePayload

allEvents

BulkEventData[]

Returns

Promise<number>

The total number of inserted rows.

Last updated on