Follow

Mmm… how’d you like to persist and retrieve custom objects from your JavaScript database?

class Dog {
constructor(excitementLevel = 1) {
this.excitementLevel = excitementLevel
}
bark ()
{
console.log('Woof! '.repeat(this.excitementLevel) }
}
}

db = JSDB.open('db')

if (!db.dogs) {
db.dogs = [
new Dog(10), new Dog(3)
]
}

db.dogs[1].bark()

// Outputs: Woof! Woof! Woof!

Coming soon to JSDB (and Site.js) ;)

github.com/small-tech/jsdb/iss

· · Web · 0 · 2 · 6
Sign in to participate in the conversation
Aral’s Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!