Skip to content

tomsdoo/pgkvs

Repository files navigation

@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

})();

About

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

Resources

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published