4 Replies
🚨 Alpha is live 🚨
A few important notes:
- For now, check out the
test
directory to understand how to get going. In particular these three files:
- test/convex/schema.ts
– This is where you define your Confect schema. Be sure to also export default
the Convex version of the schema!
- test/convex/confect.ts
– This is where you define and export the Confect versions of Convex functions. You can probably just copy the contents of this file. I think I'd prefer to just generate it for the user at some point.
- test/convex/functions.ts
– Here are lots of simple examples how to write Confect functions!
- Note that for now, at least, any optional field Schemas (i.e. { foo?: string }
) you define must use Schema.optionalWith(Schema.String, { exact: true })
. Schema.optional(Schema.String)
will fail to compile. I'll explain in the README why this is necessary eventually—or just remove this restriction.
- Confect functions may not return undefined
or void
—use null
(and Schema.Null
as the returns
validator) instead. Convex coerces undefined
/void
returns to null
anyways (in the JS API, at least)—so this just makes it more explicit.
- This probably goes without saying, but the API, though in its fundamentals is very close to final, is not stable. But I want to get it there—alongside some documentation, of course—ASAP.
Hopefully this is enough to get you started. Thanks for being user #1 ❤️ If you run into any issues or have any feedback, definitely let me know!
And to anyone else who may be reading this, please feel free to give it a go as well (with the above caveats in mind)!Thanks RJ!
@RJ is it possible to get enums working in the schema eg
Using union with literal now
Yeah Union with Literal is the intended way to do that, but I could probably support Enums too!