fix: don't support old queries and mutators in schema

This commit is contained in:
Max Koon
2025-10-15 06:44:52 -04:00
parent bbe86f6049
commit 23987e4f87
7 changed files with 20 additions and 13 deletions

View File

@@ -17,6 +17,7 @@ import {
} from "@money/shared"; } from "@money/shared";
import type { AuthData } from "@money/shared/auth"; import type { AuthData } from "@money/shared/auth";
import { getHono } from "./hono"; import { getHono } from "./hono";
import { db } from "./db";
const processor = new PushProcessor( const processor = new PushProcessor(
@@ -30,6 +31,12 @@ const createMutators = (authData: AuthData | null) => {
const mutators = createMutatorsShared(authData); const mutators = createMutatorsShared(authData);
return { return {
...mutators, ...mutators,
link: {
...mutators.link,
async create() {
console.log("Here is my function running on the server!!!");
}
}
} as const satisfies Mutators; } as const satisfies Mutators;
} }

View File

@@ -44,7 +44,7 @@ export default function RootLayout() {
<ZeroProvider {...zeroProps}> <ZeroProvider {...zeroProps}>
<Stack> <Stack>
<Stack.Protected guard={!isPending && !!session}> <Stack.Protected guard={!isPending && !!session}>
<Stack.Screen name="index" /> <Stack.Screen name="index" options={{ headerShown: false }} />
</Stack.Protected> </Stack.Protected>
<Stack.Protected guard={!isPending && !session}> <Stack.Protected guard={!isPending && !session}>
<Stack.Screen name="auth" /> <Stack.Screen name="auth" />

View File

@@ -32,6 +32,9 @@ export default function HomeScreen() {
<Button onPress={() => { <Button onPress={() => {
z.mutate.transaction.deleteAll(); z.mutate.transaction.deleteAll();
}} title="Delete" /> }} title="Delete" />
<Button onPress={() => {
z.mutate.link.create();
}} title="Open link" />
</SafeAreaView> </SafeAreaView>
); );
} }

View File

@@ -12,7 +12,7 @@
"drizzle-zero": "^0.14.3" "drizzle-zero": "^0.14.3"
}, },
"scripts": { "scripts": {
"generate:zero": "drizzle-zero generate -s ./src/db/schema/public.ts -o ./src/zero-schema.gen.ts -f", "generate:zero": "drizzle-zero generate -s ./src/db/schema/public.ts -o ./src/zero-schema.gen.ts -f && sed -i 's/enableLegacyQueries: true,/enableLegacyQueries: false,/g' src/zero-schema.gen.ts && sed -i 's/enableLegacyMutators: true,/enableLegacyMutators: false,/g' src/zero-schema.gen.ts",
"db:migrate": "drizzle-kit push" "db:migrate": "drizzle-kit push"
} }
} }

View File

@@ -22,7 +22,10 @@ export function createMutators(authData: AuthData | null) {
for (const i of t) { for (const i of t) {
await tx.mutate.transaction.delete({ id: i.id }); await tx.mutate.transaction.delete({ id: i.id });
} }
} },
},
link: {
async create() {}
} }
} as const; } as const;
} }

View File

@@ -1,10 +1,4 @@
import { type Schema as ZeroSchema, definePermissions } from "@rocicorp/zero"; import { definePermissions } from "@rocicorp/zero";
import { schema as genSchema } from "./zero-schema.gen"; import { schema } from "./zero-schema.gen";
export const schema = {
...genSchema,
enableLegacyMutators: false,
enableLegacyQueries: false,
} satisfies ZeroSchema;
export const permissions = definePermissions(schema, () => ({})); export const permissions = definePermissions(schema, () => ({}));

View File

@@ -138,8 +138,8 @@ export const schema = {
}, },
}, },
relationships: {}, relationships: {},
enableLegacyQueries: true, enableLegacyQueries: false,
enableLegacyMutators: true, enableLegacyMutators: false,
} as const; } as const;
/** /**