Upgrade to 0.4
Rename the relation count key from _count to count before the alias is removed in 0.5.
_count is now count
The relation count key lost its underscore, in include, in the result, and in orderBy. The aggregate and groupBy operators use plain names too, so the API has one convention.
const users = await client.users.findMany({
include: { _count: { select: { posts: true } } },
orderBy: { posts: { _count: 'desc' } },
});
// { id: 1, name: 'Ana', _count: { posts: 12 } }_countstill works in 0.4 as a deprecated alias. The types carry@deprecated, and the first use in a process emits aDeprecationWarningwith the codeBETTER_DRIZZLE_COUNT_DEPRECATED.- The result key follows the key you used:
_countreturns_count,countreturnscount. - Using
countand_countin the sameinclude, or in the sameorderByobject, throwsINVALID_ARGS. - The alias is removed in 0.5.
Reserved names
count now always means the relation count in include. If a relation is named count, rename it before upgrading. See reserved names.
The better-drizzle/zod, better-drizzle/ata, and cache plugins accept both spellings in 0.4. The ATA JSON Schema marks _count as deprecated.