electronade-pgstore-util
v0.1.0
Published
It's an npm package that provides some utilities for electronade-pgstore.
Downloads
7
Readme
electronade-pgstore-util
It's a package that provides some utilities for electronade-pgstore
.
See electronade-pgstore-util.netlify.app also.
It's an optional module for electronade-pgstore
so electronade-pgstore
should be installed before using electronade-pgstore-util
.
Installation
npm install electronade-pgstore-util
Interfaces
class PgStore {
constructor(connectionString: string, tableName: string, exposedName?: string);
public getAll() => Promise<any>;
public get(id: string) => Promise<any>;
public save(item: object) => Promise<object>;
public remove(id: string) => Promise<boolean>;
}
Usage
import and use PgStore class in Renderer process.
import { PgStore } from "electronade-pgstore-util";
const store = new PgStore(
"postgres://...",
"tableName"
);
const item = await store.save({ name: "test" });
console.log(item); // { _id: "xxx", name: "test" }
console.log(
await store.get(item.id)
); // { _id: "xxx", name: "test" }
console.log(
await store.getAll()
); // [{ _id: "xxx", name: "test" }]
console.log(
await store.remove(item._id)
); // true