1.2.0 • Published 5 months ago

@tomsd/pgkvs v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@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 PostgreSQL

ci checks top language

npm.io

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

})();
1.2.0

5 months ago

1.1.0

2 years ago

1.0.2

3 years ago

1.0.0

3 years ago