MCPcopy
hub / github.com/drizzle-team/drizzle-orm / count

Function count

integration-tests/tests/bun/bun-sql.test.ts:1933–1939  ·  view source on GitHub ↗
(value: PgColumn | SQLWrapper, alias?: string)

Source from the content-addressed store, hash-verified

1931 function count(value: PgColumn | SQLWrapper): SQL<number>;
1932 function count(value: PgColumn | SQLWrapper, alias: string): SQL.Aliased<number>;
1933 function count(value: PgColumn | SQLWrapper, alias?: string): SQL<number> | SQL.Aliased<number> {
1934 const result = sql`count(${value})`.mapWith(Number);
1935 if (!alias) {
1936 return result;
1937 }
1938 return result.as(alias);
1939 }
1940
1941 await db.insert(usersTable).values([{ name: 'John' }, { name: 'Jane' }]);
1942

Callers

nothing calls this directly

Calls 3

sqlFunction · 0.90
mapWithMethod · 0.80
asMethod · 0.45

Tested by

no test coverage detected