Skip to content

Commit 2a1caa4

Browse files
committed
fix seed
1 parent 564a78d commit 2a1caa4

File tree

22 files changed

+220
-22
lines changed
  • exercises
    • 03.resources
    • 04.prompts
      • 01.problem.prompts/src/db
      • 01.solution.prompts/src/db
      • 02.problem.optimized-prompt/src/db
      • 02.solution.optimized-prompt/src/db
      • 03.problem.completion/src/db
      • 03.solution.completion/src/db
    • 05.sampling

22 files changed

+220
-22
lines changed

exercises/03.resources/01.problem.simple/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

exercises/03.resources/01.solution.simple/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

exercises/03.resources/02.problem.template/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

exercises/03.resources/02.solution.template/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

exercises/03.resources/03.problem.list/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

exercises/03.resources/03.solution.list/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

exercises/03.resources/04.problem.completion/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

exercises/03.resources/04.solution.completion/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

exercises/03.resources/05.problem.linked/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

exercises/03.resources/05.solution.linked/src/db/seed.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import fs from 'node:fs/promises'
12
import path from 'node:path'
23
import { DB } from './index.js'
34

45
async function seed() {
5-
const db = DB.getInstance(path.join(process.cwd(), 'db.sqlite'))
6+
const dbPath = path.join(process.cwd(), 'db.sqlite')
7+
const dbExists = await fs.stat(dbPath).then(
8+
() => true,
9+
() => false,
10+
)
11+
// delete the db file if it exists
12+
if (dbExists) await fs.unlink(dbPath)
13+
14+
const db = DB.getInstance(dbPath)
615

716
// Helper to run raw SQL (DB class does not expose this, so we use createTag etc. for clearing)
817
// We'll clear by deleting all entries via getEntries/getTags and deleteEntry/deleteTag

0 commit comments

Comments
 (0)