Happy Friday! We have a little patch release for you with a couple of new goodies. Stay tuned for some big updates coming soon.
Infer<typeof schemaValue>
We’ve added a new Infer type helper to turn pieces of your Convex schema into TypeScript types:
import { defineSchema, defineTable, Infer, s } from "convex/schema";
const nestedObject = s.object({
property: s.string(),
});
// Resolves to `{property: string}`.
export type NestedObject = Infer<typeof nestedObject>;
export default defineSchema({
tableName: defineTable({
nested: nestedObject,
}),
});
Remember that if you need the type of the documents in a table, you can always access that with Document<TableName>.
Minor Updates
- Within database queries, you can now put the
.order(...)clause after.filter(...). This will feel more familiar if you’re coming from a SQL background. - We’re no longer generating
convex/actions/tsconfig.jsonin new projects. Given the inter-connected nature of theconvex/directory, having a singleconvex/tsconfig.jsonfile to configure TypeScript is simpler. To update to the new format, deleteconvex/tsconfig.jsonandconvex/actions/tsconfig.jsonand runnpx convex codegen --init. - There are two new system environment variables:
CONVEX_CLOUD_URLandCONVEX_SITE_URL. - Convex now supports
TextEncoder,TextDecoder,DOMException,atob,btoa, andconsole.tracewithin queries, mutations, and HTTP endpoints. - The
ConvexReactClientnow enqueues action requests when the client is offline and syncs them upon reconnection.