This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AnyColumn, InferColumnsDataTypes, SQL, Table, sql } from "drizzle-orm"; | |
export function jsonAgg<T extends Record<string, AnyColumn>>(select: T): SQL<InferColumnsDataTypes<T>[]>; | |
export function jsonAgg<T extends Table>(select: T): SQL<T["$inferSelect"][]>; | |
export function jsonAgg<T extends Record<string, AnyColumn> | Table>(select: T) { | |
const chunks: SQL[] = []; | |
var notNullColumn; | |
Object.entries(select).forEach(([key, column], index) => { | |
if (index > 0) { |