Skip to content

Commit

Permalink
feat: allow create database from seed
Browse files Browse the repository at this point in the history
  • Loading branch information
notrab committed Jan 18, 2024
1 parent 6108a91 commit 184a73a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
File renamed without changes.
20 changes: 19 additions & 1 deletion src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,26 @@ export class DatabaseClient {

async create(
dbName: string,
options?: { image: "latest" | "canary"; group?: string }
options?: {
image: "latest" | "canary";
group?: string;
seed?: {
type: "database" | "dump";
name?: string;
url?: string;
timestamp?: string;
};
}
): Promise<Database> {
if (options?.seed) {
if (options.seed.type === "database" && !options.seed.name) {
throw new Error("Seed name is required when type is 'database'");
}
if (options.seed.type === "dump" && !options.seed.url) {
throw new Error("Seed URL is required when type is 'dump'");
}
}

const response = await TursoClient.request<{ database: Database }>(
`organizations/${this.config.org}/databases`,
this.config,
Expand Down

0 comments on commit 184a73a

Please sign in to comment.