From 3f27e096283b6b477c4a66d0a7df52feaa3f4233 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 8 Mar 2024 02:21:03 +0100 Subject: [PATCH] Rename `defineDB` to `defineDb` (#10364) * Rename `defineDB` to `defineDb` * Add changeset * Improve changeset --- .changeset/wet-kiwis-laugh.md | 8 ++++++++ packages/astro/src/cli/add/index.ts | 4 ++-- packages/db/src/runtime/config.ts | 2 +- packages/db/test/fixtures/basics/db/config.ts | 4 ++-- packages/db/test/fixtures/integrations/db/config.ts | 4 ++-- .../db/test/fixtures/integrations/integration/config.ts | 4 ++-- packages/db/test/fixtures/recipes/db/config.ts | 4 ++-- packages/db/test/fixtures/ticketing-example/db/config.ts | 4 ++-- packages/db/virtual.d.ts | 2 +- 9 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 .changeset/wet-kiwis-laugh.md diff --git a/.changeset/wet-kiwis-laugh.md b/.changeset/wet-kiwis-laugh.md new file mode 100644 index 0000000000..885f88951f --- /dev/null +++ b/.changeset/wet-kiwis-laugh.md @@ -0,0 +1,8 @@ +--- +"@astrojs/db": minor +"astro": patch +--- + +Renames the Astro DB `defineDB()` helper to `defineDb()` + +⚠️ Breaking change: update your imports from `astro:db` to use `defineDb` with a lowercase “b”. diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts index db79d51542..bc01d2f50d 100644 --- a/packages/astro/src/cli/add/index.ts +++ b/packages/astro/src/cli/add/index.ts @@ -71,10 +71,10 @@ export default { public-hoist-pattern[]=*lit* `, DB_CONFIG: `\ -import { defineDB } from 'astro:db'; +import { defineDb } from 'astro:db'; // https://astro.build/db/config -export default defineDB({ +export default defineDb({ tables: {} }); `, diff --git a/packages/db/src/runtime/config.ts b/packages/db/src/runtime/config.ts index f208875370..04229eb219 100644 --- a/packages/db/src/runtime/config.ts +++ b/packages/db/src/runtime/config.ts @@ -41,7 +41,7 @@ export function defineTable(userConfig: TableCon return userConfig; } -export function defineDB(userConfig: DBConfigInput) { +export function defineDb(userConfig: DBConfigInput) { return userConfig; } diff --git a/packages/db/test/fixtures/basics/db/config.ts b/packages/db/test/fixtures/basics/db/config.ts index 368be5cc66..137fd2650a 100644 --- a/packages/db/test/fixtures/basics/db/config.ts +++ b/packages/db/test/fixtures/basics/db/config.ts @@ -1,5 +1,5 @@ import { Themes } from './theme'; -import { column, defineDB, defineTable } from 'astro:db'; +import { column, defineDb, defineTable } from 'astro:db'; const Author = defineTable({ columns: { @@ -8,6 +8,6 @@ const Author = defineTable({ }, }); -export default defineDB({ +export default defineDb({ tables: { Author, Themes }, }); diff --git a/packages/db/test/fixtures/integrations/db/config.ts b/packages/db/test/fixtures/integrations/db/config.ts index a581d12793..b8110406ab 100644 --- a/packages/db/test/fixtures/integrations/db/config.ts +++ b/packages/db/test/fixtures/integrations/db/config.ts @@ -1,4 +1,4 @@ -import { column, defineDB, defineTable } from 'astro:db'; +import { column, defineDb, defineTable } from 'astro:db'; const Author = defineTable({ columns: { @@ -7,6 +7,6 @@ const Author = defineTable({ }, }); -export default defineDB({ +export default defineDb({ tables: { Author }, }); diff --git a/packages/db/test/fixtures/integrations/integration/config.ts b/packages/db/test/fixtures/integrations/integration/config.ts index ecead779cd..d1f1aac263 100644 --- a/packages/db/test/fixtures/integrations/integration/config.ts +++ b/packages/db/test/fixtures/integrations/integration/config.ts @@ -1,7 +1,7 @@ import { menu } from './shared'; -import { defineDB } from 'astro:db'; +import { defineDb } from 'astro:db'; -export default defineDB({ +export default defineDb({ tables: { menu, }, diff --git a/packages/db/test/fixtures/recipes/db/config.ts b/packages/db/test/fixtures/recipes/db/config.ts index 6334ba8edc..bd4d6edaf4 100644 --- a/packages/db/test/fixtures/recipes/db/config.ts +++ b/packages/db/test/fixtures/recipes/db/config.ts @@ -1,4 +1,4 @@ -import { column, defineDB, defineTable } from 'astro:db'; +import { column, defineDb, defineTable } from 'astro:db'; const Recipe = defineTable({ columns: { @@ -21,6 +21,6 @@ const Ingredient = defineTable({ foreignKeys: [{ columns: 'recipeId', references: () => [Recipe.columns.id] }], }); -export default defineDB({ +export default defineDb({ tables: { Recipe, Ingredient }, }); diff --git a/packages/db/test/fixtures/ticketing-example/db/config.ts b/packages/db/test/fixtures/ticketing-example/db/config.ts index f8148eaed3..4c07b4c9c1 100644 --- a/packages/db/test/fixtures/ticketing-example/db/config.ts +++ b/packages/db/test/fixtures/ticketing-example/db/config.ts @@ -1,4 +1,4 @@ -import { column, defineDB, defineTable } from 'astro:db'; +import { column, defineDb, defineTable } from 'astro:db'; const Event = defineTable({ columns: { @@ -24,4 +24,4 @@ const Ticket = defineTable({ }, }); -export default defineDB({ tables: { Event, Ticket } }); +export default defineDb({ tables: { Event, Ticket } }); diff --git a/packages/db/virtual.d.ts b/packages/db/virtual.d.ts index 57398d6e6f..8538812e20 100644 --- a/packages/db/virtual.d.ts +++ b/packages/db/virtual.d.ts @@ -4,6 +4,6 @@ declare module 'astro:db' { export const TRUE: typeof import('./dist/runtime/config.js').TRUE; export const FALSE: typeof import('./dist/runtime/config.js').FALSE; export const column: typeof import('./dist/runtime/config.js').column; - export const defineDB: typeof import('./dist/runtime/config.js').defineDB; + export const defineDb: typeof import('./dist/runtime/config.js').defineDb; export const defineTable: typeof import('./dist/runtime/config.js').defineTable; }