-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathtest-db-simple.ts
More file actions
53 lines (43 loc) · 1.5 KB
/
Copy pathtest-db-simple.ts
File metadata and controls
53 lines (43 loc) · 1.5 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
45
46
47
48
49
50
51
52
53
#!/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"
import { effectPatterns } from "./packages/toolkit/src/db/schema/index.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: effectPatterns.id,
title: effectPatterns.title,
skillLevel: effectPatterns.skillLevel,
category: effectPatterns.category
}).from(effectPatterns).limit(5)
return patterns
})
console.log(`\n✅ Database connected successfully!`)
console.log(`📊 Found ${result.length} patterns (showing first 5):`)
// Show first few patterns
result.forEach((pattern: any, i: number) => {
console.log(` ${i + 1}. ${pattern.title} (${pattern.skillLevel}) - ${pattern.category || 'No category'}`)
})
// Count all patterns
const count = yield* Effect.tryPromise(async () => {
const result = await db.select({ count: effectPatterns.id }).from(effectPatterns)
return result.length
})
console.log(`\n📈 Total patterns in database: ${count}`)
} finally {
yield* Effect.promise(() => close())
}
})
// Run the test
Effect.runPromise(testProgram).catch((error) => {
console.error("❌ Test failed:", error)
process.exit(1)
})