feat(convex): add full domain schema and snapshot sync bridge
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { mutation, query } from "./_generated/server";
|
||||
import { v } from "convex/values";
|
||||
import { syncFromEngineSnapshot } from "./domain";
|
||||
|
||||
export const getLatestSnapshot = query({
|
||||
args: {},
|
||||
@@ -29,17 +30,26 @@ export const saveSnapshot = mutation({
|
||||
.order("desc")
|
||||
.first();
|
||||
|
||||
const syncSummary = await syncFromEngineSnapshot(ctx, args.snapshot);
|
||||
|
||||
if (latest) {
|
||||
await ctx.db.patch(latest._id, {
|
||||
snapshot: args.snapshot,
|
||||
updatedAt: args.updatedAt,
|
||||
});
|
||||
return latest._id;
|
||||
return {
|
||||
snapshotId: latest._id,
|
||||
syncSummary,
|
||||
};
|
||||
}
|
||||
|
||||
return ctx.db.insert("state_snapshots", {
|
||||
const snapshotId = await ctx.db.insert("state_snapshots", {
|
||||
snapshot: args.snapshot,
|
||||
updatedAt: args.updatedAt,
|
||||
});
|
||||
return {
|
||||
snapshotId,
|
||||
syncSummary,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user