#jsdb — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #jsdb, aggregated by home.social.
-
🥳 New JavaScript Database (JSDB) release
• Fix: Now properly handling array indices on `JSTable.PERSIST` events in the `keypath` property that’s passed to the event handler.
Just noticed that the pretty keypaths of the JavaScript deltas written to the append-only log were ignoring array indices while playing with a new database introspection call I’m adding to the Kitten Interactive Shell (REPL) and fixed it.
I’ll be updating Kitten shortly to use this version of JSDB and I haven’t forgotten my promise to record a little video of the new Kitten Introspection API.
Enjoy!
💕
https://codeberg.org/small-tech/jsdb#readme
#JavaScriptDatabase #javascript #database #JSDB #SmallTech #SmallWeb #NodeJS
-
Just made a little correction to the JavaScript Database (JSDB) Table Events section:
Previously, the example that listens for the JSTable.PERSIST event was erroneously stating that the table was deleted when the `type` property in the event handlers parameter object was JSTable.DELETE. It now correctly states that the value at `keypath` was deleted.
I also documented the JSTable.PERSIST types so they wouldn’t be confused with the JSTable event types (persist and delete; the latter of which does actually signal that the table – i.e., the append-only JavaScript log – was deleted.
https://codeberg.org/small-tech/jsdb#table-events
#SmallWeb #SmallTech #JavaScript #database #JSDB #documentation #events #fix
-
🥳 JavaScript Database (JSDB)¹ version 7.0.0 released
- *Breaking change* JSTable.PERSIST event now uses a parameter object with properties for `type`, `keypath`, `value`, `change`, and `table`. This should make listening for events on your databases much nicer to author. e.g., a snippet from Catalyst² I’m working on:
```js
const settingsTable = db.settings['__table__']
const JSTable = settingsTable.constructorsettingsTable.addListener(JSTable.PERSIST, ({ keypath, value }) => {
switch (keypath) {
case 'servers.serverPoolSize':
console.info('New server pool size requested', value)
this.updateServerPool()
break
// etc.
}
})
```This new version of JSDB is not in the latest Kitten³ yet as it is a breaking change and I want to make sure I update my sites/apps first if needed. I should have it integrated tomorrow.
To see the simple use case for JSDB in Kitten (the default untyped database that’s easy to get started with and perfect for quick experiments, little sites, etc.), see: https://kitten.small-web.org/tutorials/persistence/
For a more advanced tutorial for creating your own typed databases in Kitten, see the Database App Modules tutorial: https://kitten.small-web.org/tutorials/database-app-modules/
For another example, see: https://codeberg.org/small-tech/jsdb/#table-events
Full change log: https://codeberg.org/small-tech/jsdb/src/branch/main/CHANGELOG.md#7-0-0-2026-02-10
Enjoy!
💕
¹ https://codeberg.org/small-tech/jsdb#readme
² https://catalyst.small-web.org
³ https://kitten.small-web.org#JavaScriptDatabase #JavaScript #appendOnlyLog #JS #JSDB #JSDBUpdates #SmallTech #SmallWeb #Kitten #Catalyst
-
🔒 New Kitten & JSDB Releases
Security fix, JSDB 6.0.1.
This is a critical update.
• JSDB¹ versions 6.0.0 and below suffer from potential data corruption/arbitrary code execution as string keys were not being sanitised in the same way string values were² (so this is relevant to you if you’re storing untrusted data as keys in your data structures in JSDB and/or Kitten databases without carrying out any of your own sanitisation at the application level).
• The latest Kitten release uses JSDB version 6.0.1. Your deployment servers will automatically update in the next few hours. On your development machines, please run `kitten update` in your terminal or use the Update feature in Kitten Settings from your browser.
• If you are using Kitten’s Database App Modules³ feature in your apps, you will have installed JSDB manually and you should update your installation to version 6.0.1.
¹ https://codeberg.org/small-tech/jsdb/
² https://codeberg.org/small-tech/jsdb/issues/22
³ https://kitten.small-web.org/reference/#database-app-modules#Kitten #SmallWeb #JSDB #JavaScriptDatabase #KittenRelease #JSDBRelease #securityUpdate #criticalUpdate
-
While working on porting the Small Technology Foundation web site¹ to Kitten², I took the opportunity to pull out base Model and Collection classes that I’ll likely end up including in Kitten proper:
• Model: https://codeberg.org/small-tech/site/src/branch/kitten/app_modules/database/Model.js
• Collection: https://codeberg.org/small-tech/site/src/branch/kitten/app_modules/database/Collection.jsTo see them in use, here’s the base Posts class (with RSS generation) that extends Collection:
https://codeberg.org/small-tech/site/src/branch/kitten/app_modules/database/Posts.jsAnd here’s the concrete EventPosts collection class that extends Posts:
https://codeberg.org/small-tech/site/src/branch/kitten/app_modules/database/EventPosts.jsAnd the EventPost (showing an implementation of a calculated property):
https://codeberg.org/small-tech/site/src/branch/kitten/app_modules/database/EventPost.jsSo all this is possible (persisting and reading back typed model collections, etc.) thanks to JSDB¹ (JavaScript database), a zero-dependency, transparent, in-memory, streaming write-on-update JavaScript database I wrote for the Small Web that persists to a JavaScript transaction log and is included as as first-class citizen in Kitten.
https://codeberg.org/small-tech/jsdb
And if you want to know how the magic mapping of classes happens, see the Database App Module:
https://codeberg.org/small-tech/site/src/branch/kitten/app_modules/database/database.js#L34
PS. For a much gentler introduction to persistence in Kitten, see the Kitten Persistence tutorial:
https://kitten.small-web.org/tutorials/persistence/Enjoy! :kitten:💕
¹ https://small-tech.org
² https://kitten.small-web.org#Kitten #SmallWeb #SmallTech #JavaScript #database #JSDB #typeSafety #JSDoc #closureCompiler #TypeScript #workInProgress
-
Just updated the Database App Modules tutorial in the Kitten documentation to fix a few bugs, update to latest Kitten syntax, and improve the instructions:
https://kitten.small-web.org/tutorials/database-app-modules/
(Database app modules are special app modules¹ that let you create strongly-typed JavaScript databases² in your Small Web³ apps.)
Enjoy!
:kitten:💕
¹ https://kitten.small-web.org/reference/#app-modules
² https://codeberg.org/small-tech/jsdb#readme
³ https://ar.al/2024/06/24/small-web-computer-science-colloquium-at-university-of-groningen/#Kitten #DatabaseAppModules #AppModules #tutorial #SmallWeb #SmallTech #web #dev #JSDB #JavaScriptDatabase #JavaScript #database #web #dev #NodeJS #strongTyping
-
Assign properties in a constructor’s parameter object (with defaults) to object being instantiated in JavaScript
This is a little something I ended up playing around with this morning before figuring out how to do it (after spending far too much time down a rabbit hole with object destructuring when what I really needed was creative use of the spread operator).
(Useful for custom objects in JSDB 5 – https://codeberg.org/small-tech/jsdb#custom-data-types)
-
Heads up anyone playing with Kitten at the moment (yes, both of you):
I’m in the process of upgrading Kitten’s version of JSDB from 4 to 5.
*This is a breaking change.*
This will affect you if you’re persisting custom objects (instances of your custom model classes) in your databases.
Please see the details in this JSDB announcement post and the linked-to details page to prepare:
https://mastodon.ar.al/@aral/112361559531645603
(I should have the update out this afternoon.)
-
Philosophically, JSDB – which writes out to native JavaScript logs – is very much the JavaScript version of SWX, the native data format for Flash that I released around 2007 (where data was written out in native SWF format). I have to say that I’m glad I didn’t have to reverse engineer SWF bytecode this time around :)
Here’s a video of a younger me doing an impromptu demo of SWX at some conference or other from 16 years ago.
-
Realised last night that JavaScript Database (JSDB) doesn’t run the constructor on persisted custom objects (https://codeberg.org/small-tech/jsdb#custom-data-types) when deserialising them because I didn’t know that you apparently have to define your constructor manually when using Object.create().
Will fix it today but it’s something to watch out for if you’re using Object.create() directly.
For more info, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create
#JSDB #customObjects #constructor #bug #JavaScript #NodeJS #SmallTech #SmallWeb
-
So it’s very much still an early work-in-progress but I’ve renamed WhatDB to JavaScript Database (JSDB) as it now streams and writes to an append-only transaction log in pure JavaScript:
https://github.com/small-tech/jsdb
(This is what I mentioned I wanted to try last week in my post “What if data was code?” https://ar.al/2020/09/23/what-if-data-was-code/)