TypeScript toJSON should return real schema
See original GitHub issueDescribe the solution you’d like I want to get the real schema when i use toJSON();
Why should this be in Sequelize It is more good for TypeScript
Usage example How can the requested feature be used to approach the problem it’s supposed to solve.
const result = await Model.findOne();
const obj = result.toJSON(); // model schema
const id = obj.id; // number
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Generate json-schema from your Typescript sources - GitHub
Generate json-schemas from your Typescript sources. Features. Compiles your Typescript program to get complete type information. Translates required properties, ...
Read more >Using with TypeScript - Ajv JSON schema validator
Utility types for schemas. For the same example as in Getting started: ensure strictNullChecks is true. JSON Schema; JSON Type ...
Read more >Enforcing Types on your JSON? Yes you can! - Bits and Pieces
JSON Schema for the JavaScript fanatics. It is well known that if you're into types and JavaScript, you're likely better off writing TypeScript....
Read more >Top 5 json-schema-to-typescript Code Examples - Snyk
To help you get started, we've selected a few json-schema-to-typescript examples, based on popular ways it is used in public projects.
Read more >How do I cast a JSON Object to a TypeScript class?
For now, you could either use a json schema validator which purpose is ... In a real world example, I would have it...
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 Free
Top 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
Currently, for the lack of a model schema on
toJSON()
return:Ultimately, this would be because
.get()
doesn’t have a model schema attached. Since, (I believe),toJSON()
is really calling.get()
Because the point of
toJSON
is to be compatible withJSON.stringify
and nothing else, it’s not meant for direct consumption.Closing this thread, use
.get()