lapisdb
v0.4.4
Published
A TypeScript database built on top of LevelDB - a fast and efficient C++ database.
Downloads
40
Readme
💥 LapisDB
A TypeScript embedded database that is really easy and nice to use.
Attention
I am still working on this project, and many things might change in future.
Example
You can check out a full REST API here.
const adapter = new LevelDbAdapter(News, { name: 'news', directory: './database' })
const db = new Datastore('news', adapter)
DatastoreManager.register(db)
export class News extends Model<News> {
body: string;
author: string;
constructor(body: string, author: string) {
super(News)
this.body = body
this.author = author
}
}
// Getting items
const items: News[] = await db.getItems()
// Filtering results
const items: News[] = await db.getItems((n) => n.author === 'kekland')
// Getting single item
const item: News = await db.get('identifier')
// Getting single item through its parameters
const item: News = await db.get({author: 'kekland'})
// Adding an item
const newItem: News = await new News('interesting body', 'kekland').save()
// Editing an item
newItem.body = 'a more interesting body'
await newItem.save()
// Getting a reference to an item
const reference: Reference<News> = newItem.getReference()
// Getting an item through its reference
console.log((await reference.get(News)) === newItem) // true
// Deleting an item
await newItem.delete()
Why?
During my experience writing servers, I often cannot find a database that is both fast and easy to use.
LapisDB tries to solve this problem. It is fully typed and uses TypeScript to make the development process a blast.
Try it out!
cd my-awesome-project
npm install --save lapisdb
How do I use it?
📋 Tutorial
Check out the GitHub Wiki page here.
📕 Documentation
You can find the full TypeDoc documentation here (not updated as of v0.3.0).
Plugins, additional features
Contact me
E-Mail: [email protected]