Home / Function/ pushToDb() — astro Function Reference

pushToDb() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  fd485177_700f_c3cc_9169_090bb47ed166["pushToDb()"]
  d792b779_355c_47a7_c602_04c8b8882820["index.ts"]
  fd485177_700f_c3cc_9169_090bb47ed166 -->|defined in| d792b779_355c_47a7_c602_04c8b8882820
  87af403c_099b_77aa_edce_f10307a1f2a4["pushSchema()"]
  87af403c_099b_77aa_edce_f10307a1f2a4 -->|calls| fd485177_700f_c3cc_9169_090bb47ed166
  style fd485177_700f_c3cc_9169_090bb47ed166 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/db/src/core/cli/commands/push/index.ts lines 115–137

async function pushToDb(requestBody: RequestBody, appToken: string, remoteUrl: string) {
	const client = createClient({
		token: appToken,
		url: remoteUrl,
	});

	await client.run(sql`create table if not exists _astro_db_snapshot (
		id INTEGER PRIMARY KEY AUTOINCREMENT,
		version TEXT,
		snapshot BLOB
	);`);

	await client.transaction(async (tx) => {
		for (const stmt of requestBody.sql) {
			await tx.run(sql.raw(stmt));
		}

		await tx.run(sql`insert into _astro_db_snapshot (version, snapshot) values (
			${requestBody.version},
			${JSON.stringify(requestBody.snapshot)}
		)`);
	});
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does pushToDb() do?
pushToDb() is a function in the astro codebase, defined in packages/db/src/core/cli/commands/push/index.ts.
Where is pushToDb() defined?
pushToDb() is defined in packages/db/src/core/cli/commands/push/index.ts at line 115.
What calls pushToDb()?
pushToDb() is called by 1 function(s): pushSchema.

Analyze Your Own Codebase

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

Try Supermodel Free