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

View File

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

View File

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

View File

@@ -12,7 +12,7 @@
"drizzle-zero": "^0.14.3"
},
"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"
}
}

View File

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

View File

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

View File

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