Adding typing and JSON validation to the database #2
Replies: 1 comment 7 replies
-
|
I agree - automation always helps and should be used for building up indexes and lists to ensure up-to-date and accurate files. Providing the database in JSON format should make it easy for us and external users to query and process data via web requests. This could even be used later to implement a dedicated API as an abstraction layer without requiring access to databases such as SQL or Mongo, which involves ongoing server costs. GitHub and open access to data via CDNs (such as jsDelivr) allow data to be available around the clock and worldwide, offering unlimited queries and speed. Structures are incredibly important and should be the key to everything. Especially right now - without anything that relies on those files, we can respond very flexibly to requirements and should not rush into it. The data currently available has been taken from the previous database (https://github.com/komed3/periodic-table) and split into folders and files for demonstrative purposes. Its structure isn't strictly defined, and I'd even recommend making urgent adjustments to ensure better type safety and simpler schemas. An example: Values can currently be given in simple form or as an array, which makes it much more difficult to predict the actual data types and, despite TypeScript, always involves a variable part. I think a simple but “descriptive” basic structure for a value should allow users to handle the data better and also be beneficial in terms of parsing such values. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The database format, for now, seems to aim around being JSON files, in dedicated folders and subfolders.
But as the database grows and time passes, I'm pretty much foresee a point where, at least I, fail to remember with exactitude what is inside all of this, and what is maybe inside.
typescript
The benefits of using typescripts are as follows:
However typescript cannot be used directly against a JSON file to confirm its adherence to the type system, only a JSON schema format can do.
JSON-schema types
JSON-schema types is a format that when run with a javascript validator like AJV, ensure that a JSON file respect a format. Making it useful to ensure that the JSON you have is indeed the JSON you expect and you didn't made a typo in the naming.
Downside of this format is that writing it manually is a big pain, that's why I only do automatically it with typescript.
In short
The workflow I'm proposing is as follow:
i'll open a second discussion about adding a javascript runtime because all of that here will at one point need to have scripts running.
Beta Was this translation helpful? Give feedback.
All reactions