Home / Function/ asDrizzleTable() — astro Function Reference

asDrizzleTable() — astro Function Reference

Architecture documentation for the asDrizzleTable() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  29c39cb4_cd06_6b43_331c_079cec6b23f4["asDrizzleTable()"]
  80ef4dc8_c183_c77f_e09f_d40d9a6ca694["index.ts"]
  29c39cb4_cd06_6b43_331c_079cec6b23f4 -->|defined in| 80ef4dc8_c183_c77f_e09f_d40d9a6ca694
  3099e947_8164_4013_6b72_f4b301ca60d1["columnMapper()"]
  29c39cb4_cd06_6b43_331c_079cec6b23f4 -->|calls| 3099e947_8164_4013_6b72_f4b301ca60d1
  9010288e_179e_249f_18af_1b89260e1a28["atLeastOne()"]
  29c39cb4_cd06_6b43_331c_079cec6b23f4 -->|calls| 9010288e_179e_249f_18af_1b89260e1a28
  style 29c39cb4_cd06_6b43_331c_079cec6b23f4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/db/src/runtime/index.ts lines 56–76

export function asDrizzleTable(name: string, table: DBTable) {
	const columns: Record<string, D1ColumnBuilder> = {};
	if (!Object.entries(table.columns).some(([, column]) => hasPrimaryKey(column))) {
		columns['_id'] = integer('_id').primaryKey();
	}
	for (const [columnName, column] of Object.entries(table.columns)) {
		columns[columnName] = columnMapper(columnName, column);
	}
	const drizzleTable = sqliteTable(name, columns, (ormTable) => {
		const indexes: Array<IndexBuilder> = [];
		for (const [indexName, indexProps] of Object.entries(table.indexes ?? {})) {
			const onColNames = Array.isArray(indexProps.on) ? indexProps.on : [indexProps.on];
			const onCols = onColNames.map((colName) => ormTable[colName]);
			if (!atLeastOne(onCols)) continue;

			indexes.push(index(indexName).on(...onCols));
		}
		return indexes;
	});
	return drizzleTable;
}

Domain

Subdomains

Frequently Asked Questions

What does asDrizzleTable() do?
asDrizzleTable() is a function in the astro codebase, defined in packages/db/src/runtime/index.ts.
Where is asDrizzleTable() defined?
asDrizzleTable() is defined in packages/db/src/runtime/index.ts at line 56.
What does asDrizzleTable() call?
asDrizzleTable() calls 2 function(s): atLeastOne, columnMapper.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free