MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / createClient

Function createClient

tests/runtimes/bun/bun-e2e.test.ts:91–118  ·  view source on GitHub ↗
(provider: 'sqlite' | 'postgresql', dbName: string)

Source from the content-addressed store, hash-verified

89});
90
91async function createClient(provider: 'sqlite' | 'postgresql', dbName: string) {
92 const _schema = clone(schema);
93 let dialect: Dialect;
94 if (provider === 'sqlite') {
95 (_schema as any).provider.type = 'sqlite';
96 dialect = new BunSqliteDialect({
97 database: new Database(':memory:'),
98 });
99 } else {
100 (_schema as any).provider.type = 'postgresql';
101 const pgClient = new Client({
102 connectionString: TEST_PG_URL,
103 });
104 await pgClient.connect();
105 await pgClient.query(`DROP DATABASE IF EXISTS "${dbName}"`);
106 await pgClient.query(`CREATE DATABASE "${dbName}"`);
107 await pgClient.end();
108 dialect = new PostgresDialect({
109 pool: new Pool({
110 connectionString: `${TEST_PG_URL}/${dbName}`,
111 }),
112 });
113 }
114
115 const db = new ZenStackClient(_schema, { dialect });
116 await db.$pushSchema();
117 return db;
118}

Callers 1

bun-e2e.test.tsFile · 0.70

Calls 2

cloneFunction · 0.90
$pushSchemaMethod · 0.80

Tested by

no test coverage detected