-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathtest-simple-db.ts
More file actions
44 lines (36 loc) · 1.11 KB
/
test-simple-db.ts
File metadata and controls
44 lines (36 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bun
/**
* Simple test of database connection and pattern count
*/
import { Effect } from "effect"
import { createDatabase } from "./packages/toolkit/src/db/client.js"
const testProgram = Effect.gen(function* () {
console.log("🔍 Testing database connection...")
// Create database connection
const { db, close } = createDatabase()
try {
// Simple query to count patterns
const result = yield* Effect.tryPromise(async () => {
const patterns = await db.select({
id: true,
title: true,
skillLevel: true,
category: true
}).from(db.effectPatterns || db.select().from({ effectPatterns: {} }))
return patterns
})
console.log(`\n✅ Database connected successfully!`)
console.log(`📊 Found ${result.length} patterns in database`)
// Show first few patterns
result.slice(0, 5).forEach((pattern: any, i: number) => {
console.log(` ${i + 1}. ${pattern.title} (${pattern.skillLevel})`)
})
} finally {
yield* Effect.promise(() => close())
}
})
// Run the test
Effect.runPromise(testProgram).catch((error) => {
console.error("❌ Test failed:", error)
process.exit(1)
})