←back to thread

115 points graderjs | 9 comments | | HN request time: 0.857s | source | bottom
1. yodon ◴[] No.25004762[source]
I've often looked for a simple human readable file-based DB-like system like this. Are there other competing packages like this?
replies(6): >>25004905 #>>25004915 #>>25004929 #>>25005021 #>>25005739 #>>25006504 #
2. LVB ◴[] No.25004905[source]
This is sort of in the space: https://github.com/msiemens/tinydb
3. graderjs ◴[] No.25004915[source]
I just had a quick search, didn't turn up much but there is this

https://github.com/pksunkara/nosqlite

I could add a section

4. asaibx ◴[] No.25004929[source]
There's always recutils [0] which uses a plain text database format stored in files called recfiles.

[0] https://labs.tomasino.org/gnu-recutils/

replies(1): >>25004983 #
5. graderjs ◴[] No.25004983[source]
I should add that I was inspired by recutils and considered using it before making this. The appeal of using common Unix tools to play with a database is a motivation for me
6. jitl ◴[] No.25005021[source]
I feel like many static site generators have more-or-less filesystem-as-database. Some are more specialized than others. Many SSGs have standardized around the format of `YAML: Metadata\n\n---\n\nContent`, and expose a query interface over the YAML metadata. But, most static site generators don't generally have create/update API - just a read API.

A reason you don't see much in the "tree of simple files as my DB" space is that the whole point of it is to be trivially simple to understand, and thus, to implement.

Now, with file DBs, it's actually quite important to use atomic writes, so that a crash or concurrent operations don't produce errors. For example, the package posted above can corrupt data if there's concurrent writers to the same data file, because all the writes are non-atomic fs.writeFileSync(). What this database should do instead is write to a tempfile, and then rename the tempfile to replace the destination. That way, you get simple last-write-wins semantics with no possibility of creating invalid JSONs.

7. legulere ◴[] No.25005739[source]
DBASE is largely text-based
8. leoncvlt ◴[] No.25006504[source]
This is something I wrote for a small electron application that needed some simple database functionality: https://www.npmjs.com/package/minim-json-db

Like the OP, stores data locally in .json files, and uses a simple MongoDB-inspired API

replies(1): >>25006571 #
9. graderjs ◴[] No.25006571[source]
Thanks! I'll add to related projects