@tomsd/pgkvs
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@tomsd/pgkvs

It's a key value store handler that the repository is a postgresql database, for easy-use.
See pgkvs.netlify.app for details.

npm NPM npms.io (quality) Libraries.io dependency status for latest release Maintenance

Installation

npm install @tomsd/pgkvs

Usage

import { PgKvs } from "@tomsd/pgkvs";

const uri = "postgres://...";
const tableName = "testTable";

(async () => {

  const store = new PgKvs(uri, tableName);

  const record = await store.upsert({ name: "alice" });
  console.log(record); // { _id: "xxx", name: "alice" }

  console.log(
    await store.getAll()
  ); // [{ _id: "xxx", name: "alice" }]

  console.log(
    await store.get(record._id)
  ); // { _id: "xxx", name: "alice" }

  console.log(
    await store.upsert({
      ...record,
      name: "bob",
      age: 25
    })
  ); // { _id: "xxx", name: "bob", age: 25 }

  console.log(
    await store.remove(record._id)
  ); // true

})();

Readme

Keywords

Package Sidebar

Install

npm i @tomsd/pgkvs

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

20.6 kB

Total Files

5

Last publish

Collaborators

  • tomsd