(
// Should have {VALUES} as a placeholder
queryWithPlaceholder: string,
values: Array<T>,
tag: string,
client?: PoolClient
)
| 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 |
no test coverage detected