A TypeScript embedded database that is really easy and nice to use.
I am still working on this project, and many things might change in future.
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()
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.
cd my-awesome-project
npm install --save lapisdb
Check out the GitHub Wiki page here.
You can find the full TypeDoc documentation here (not updated as of v0.3.0).
E-Mail: [email protected]