MCPcopy Index your code
hub / github.com/PostHog/posthog / postgresBulkInsert

Method postgresBulkInsert

plugin-server/src/utils/db/db.ts:256–281  ·  view source on GitHub ↗
(
        // Should have {VALUES} as a placeholder
        queryWithPlaceholder: string,
        values: Array<T>,
        tag: string,
        client?: PoolClient
    )

Source from the content-addressed store, hash-verified

254 }
255
256 public async postgresBulkInsert<T extends Array<any>>(
257 // Should have {VALUES} as a placeholder
258 queryWithPlaceholder: string,
259 values: Array<T>,
260 tag: string,
261 client?: PoolClient
262 ): Promise<void> {
263 if (values.length === 0) {
264 return
265 }
266
267 const valuesWithPlaceholders = values
268 .map((array, index) => {
269 const len = array.length
270 const valuesWithIndexes = array.map((_, subIndex) => `$${index * len + subIndex + 1}`)
271 return `(${valuesWithIndexes.join(', ')})`
272 })
273 .join(', ')
274
275 await this.postgresQuery(
276 queryWithPlaceholder.replace('{VALUES}', valuesWithPlaceholders),
277 values.flat(),
278 tag,
279 client
280 )
281 }
282
283 // ClickHouse
284

Callers 2

syncEventPropertiesMethod · 0.80

Calls 3

postgresQueryMethod · 0.95
joinMethod · 0.80
flatMethod · 0.80

Tested by

no test coverage detected