1.0.3 • Published 2 years ago
docs-store v1.0.3
docs-store
light, fast and realiable database based on json documents
api
// open store
static open<T>(baseUrl: string): Store<T>
// return all documents as array
collection = async (): Promise<Document<T>[]>
// return document data
readDoc = async (uuid: string): Promise<Document<T>>
// save data to file, then return it's uuid and data
writeDoc = async (data: T): Promise<Document<T>>
// update document data, then return it's uuid and data
updateDoc = async (uuid: string, data: T): Promise<Document<T>>
// delete document, then return it's uuid
removeDoc = async (uuid: string): Promise<Document<T>>
usage
import { Store } from "./store";
// open store
const store = Store.open<{ firstName: string; lastName: string }>("users");
// write document
let { uuid } = await store.writeDoc({ firstName: "John", lastName: "Doe" });
// print saved document uniqe uuid
console.log(`document ${uuid} saved!`);
result
users/088b593f-b2f7-4755-884d-7b99ff6de31f.json
{
"uuid": "088b593f-b2f7-4755-884d-7b99ff6de31f",
"data": {
"firstName": "John",
"lastName": "Doe"
}
}