gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitc171227ec171227emission 054: hide adult/unknown titles from the public lists and the search; in-app adult-flag backfill (TMDB details + poster per title, resumes), gate + real-data proofmrec171227e/plugins/mpackdb/README.md

2.7 KB

  1. # `hl:mpackdb` — the MessagePack file database
  2. A document store in plain files. Server realm. The class surface and its
  3. generated API docs live in `MPackDB.hl` and `cursor.hl`
  4. (`projects/homepage/docs/mpackdb.md`).
  5. ```hybriel
  6. import { MPackDB } from 'hl:mpackdb'
  7. db = new MPackDB(file = 'users.db', primaryKey = '*id', indexes = ['!email', 'age'])
  8. id = db.put({ name = "Alice"; email = "[email protected]"; age = 30; }) \\ 1
  9. ```
  10. ## Primary keys
  11. | declaration | key | generated by `put()` |
  12. |---|---|---|
  13. | `*name` | a number | the table's counter: **1, 2, 3, …** |
  14. | `@name` | a string | a random 12-character id |
  15. | `name` | a string | nothing — the record must carry it |
  16. **A fresh `*id` table starts at 1** (ticket #4, the creator's ruling "start at
  17. 1"). The counter is stored as `nextId` in `<base>.meta.json`, and an existing
  18. table keeps counting from its stored value. A table written before this rule
  19. therefore goes on from wherever it was, and its record 0 remains record 0.
  20. A record put with an explicit key takes that key if it is free, 0 included.
  21. ## One open table per process (ticket #110)
  22. Within one process, a table path has **one** open table, shared by every
  23. `open()` — another module instance, another realm, it doesn't matter, they
  24. all get the same handle. The file is never compacted or rewritten while a
  25. handle on it is live; compaction happens only when asked for explicitly
  26. (`compactNow()` / `#handle.compact()`) or when the **last** handle on that
  27. path closes. A second `open()` of an already-open table ignores its own
  28. `primaryKey`/`indexes`/`compact` arguments — the schema was fixed by whoever
  29. opened it first.
  30. This matters because compaction rewrites `<base>.mpack` and shifts every
  31. record after the first tombstone to a new offset. Before this rule, a second
  32. `open()` from anywhere in the process ran its own compact-on-open (ticket
  33. #21) against the same file, and the first handle's already-looked-up offsets
  34. went stale under it — reads through the first handle then missed or
  35. misread records until something compacted again. Related: ticket #21
  36. ("opening a table rewrote its files").
  37. ## Compatibility with the JS mpackdb
  38. The on-disk format is the JS mpackdb 1.0.7 format: `<base>.mpack`,
  39. `<base>.meta.json`, one `<base>.<field>.txt` per index, `<base>.idxstate.json`
  40. and the `<base>.lock` protocol. Either side reads and changes the other's
  41. files. The first id is not part of the format; `nextId` is. Therefore:
  42. - a table the JS mpackdb created carries `nextId` and keeps its sequence here,
  43. even when that sequence started at 0;
  44. - a table Hybriel created carries `nextId` too, and the JS mpackdb continues it;
  45. - the one divergence is a table with **no** `.meta.json` yet: Hybriel's first
  46. id is 1, the JS mpackdb's is 0.
  47. The other documented divergences are listed at the top of `engine.zig`.

Branches

Latest commits

  • c171227emission 054: hide adult/unknown titles from the public lists and the search; in-app adult-flag backfill (TMDB details + poster per title, resumes), gate + real-data proofmre
  • 47a3cae6STATUS: mission 053 merge commit idsmre
  • dcc5eecaMerge branch 't14-search'mre
  • 03edc783Merge branch 't15-tvmaze'mre
  • 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
  • 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
  • b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
  • 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
  • 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre
  • cbdc4ea7tracker#12: link icons TMDB/IMDb/TVDB/TVmaze; sync fills missing ids (TVmaze lookup); movies fetched via /movie/mre
  • b105bcd8tracker#11: Hybriel master ff51cf46 (checks no longer vanish), mobile-first styles, carets, follow button, sign-in modal, inverted check, orange castmre
  • 31b758aatracker#10: installable app (manifest, service worker, offline shell), own icon + faviconmre
  • 2fa9d997tracker#9: TMDB sync (followed shows: seasons, episodes, posters), tools/sync-tmdb.hl + daily run 04:00 UTC, fake TMDB in gatemre
  • 49e1f61edeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • 54070a4etracker#8: /my/unwatched + /my/schedule (301 from old), S01E01, title (year), 1 episode, watched-set lookup (unwatched 15s -> 1s)mre
  • 3251488atracker#7: /my/shows (followed shows, newest follow first, poster, title, last watched SxxEyy); gate can take screenshots (TRACKER_GATE_SHOTS)mre
  • 44b7d9f9tracker#6: /schedule — upcoming episodes of followed shows, soonest firstmre
  • 91c9fc8ctracker#5: /unwatched — unwatched released episodes of followed shows, newest firstmre
  • a97c0295tracker#4: show page /shows/:slug (header, seasons, episodes, watch checks) + tools/relink-episode-seasons.hlmre
  • 05f407c5tracker: no border on any button except inverted ones (Log out, ident status and identities too); header brand weight 100mre