[Feature] Statically set schemas
See original GitHub issueIt would be great if we could do something like this:
import { buildSchema } from '@camberi/firecms';
import { Category } from "@my-projects/schemas";
export const categorySchema = buildSchema<Category>({
/** everything here stays the same, but now, typescript complains if the schema mismatches with the Category. **/
});
Thanks a lot for your work here 💯
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Feature and table schemas for task parameters—ArcGIS Server
Input schemas based on Feature and Record Sets ... Custom model and script tools you create can use the Feature Set or the...
Read more >Mongoose v6.8.1: Schemas
Each schema maps to a MongoDB collection and defines the shape of the documents ... new Schema({ name: String, type: String }, {...
Read more >Using the Schema Discovery Feature on Static Data
The schema discovery feature can generate a schema from either the data in a stream or data in a static file that is...
Read more >Static variables declared on advanced schemas are not ...
When declaring a static variable on a class loaded with loadClass into the schema, the static variable does not get loaded into the...
Read more >Documentation: 15: CREATE FUNCTION - PostgreSQL
If a schema name is included, then the function is created in the specified schema. Otherwise it is created in the current schema....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @PupoSDC Thanks a lot for your PR!! I have merged it but modified it a little bit. The function you need is now called
buildSchemaFrom
and I have modified it slightly. I have also tried checking the property data types based on the Typescript types but failed! I already tried once and failed as well, I have to admit Typescript has defeated me here! I am pretty sure it’s possible but I am getting something wrong.It is not released yet, but it is merged into the
master
branch so if you would like to use it you can link your project to it directly.If anyone sees this and is willing to try, the goal is to be able to type check property data types based on a given Typescript type.
A simplified version of the model would be:
If anyone manages to get the simplified version working we can probably escalate it to the whole app 😃
Ah I understand! So getting statically type checks based on your Typescript interfaces. Makes total sense, and would make a nice enhancement. I’m adding it to the backlog. If you feel like giving a shot at the implementation let me know!