Skip to content

Commit

Permalink
adding auto seed for maps
Browse files Browse the repository at this point in the history
  • Loading branch information
webdevcody committed Oct 16, 2024
1 parent e001e00 commit 60d0649
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions convex/_generated/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type * as auth from "../auth.js";
import type * as constants from "../constants.js";
import type * as games from "../games.js";
import type * as http from "../http.js";
import type * as init from "../init.js";
import type * as maps from "../maps.js";
import type * as openai from "../openai.js";
import type * as results from "../results.js";
Expand All @@ -38,6 +39,7 @@ declare const fullApi: ApiFromModules<{
constants: typeof constants;
games: typeof games;
http: typeof http;
init: typeof init;
maps: typeof maps;
openai: typeof openai;
results: typeof results;
Expand Down
10 changes: 10 additions & 0 deletions convex/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { internalMutation } from "./_generated/server";
import { seedMaps } from "./maps";

export default internalMutation({
handler: async (ctx) => {
const maps = await ctx.db.query("maps").first();
if (maps) return;
await seedMaps(ctx, {});
},
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "npm-run-all --parallel dev:frontend dev:backend",
"dev": "npm-run-all dev:init --parallel dev:frontend dev:backend",
"dev:frontend": "next dev",
"dev:backend": "convex dev",
"dev:init": "convex dev --run init --until-success",
"predev": "convex dev --until-success && node setup.mjs --once && convex dashboard",
"build": "next build",
"start": "next start",
Expand Down

0 comments on commit 60d0649

Please sign in to comment.