pg-storage
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

Bot Builder PostgreSQL Storage

This is a simple storage adapter for PostgreSQL.

Installation

npm install pg-storage --save

Usage

import { PostgreSQLStorage } from 'pg-storage';

const storage = new PostgreSQLStorage({ 
    host: <DATABASE_HOST>,
    user: <DATABASE_USERNAME>,
    password: <DATABASE_PASSWORD>,
    server: <DATABASE_SERVER>,
    database: <DATABASE_NAME>,
    table: <DATABASE_TABLE>,
    port: <DATABASE_PORT>
});

const conversationState = new ConversationState(storage);
const userState = new UserState(storage);

If you intend to use a PostgreSQL database other than localhost, ensure that the ssl key is set to true.

    import { PostgreSQLStorage } from 'pg-storage';
    import { PostgreSQLOptions } from "pg-storage/lib/schema";

    const options: PostgreSQLOptions = {
        host: <DATABASE_HOST>,
        user: <DATABASE_USERNAME>,
        password: <DATABASE_PASSWORD>,
        server: <DATABASE_SERVER>,
        database: <DATABASE_NAME>,
        table: <DATABASE_TABLE>,
        port: <DATABASE_PORT>,
        ssl: true
    };

    const storage = new PostgreSQLStorage(options);

This module uses the node-pg package for SQL connectivity. The PostgreSQLOptions that is passed to the PostgreSQLStorage object extends the config object of that package. All options from that config option can be passed in.

This module assumes two columns in your database table: id with datatype VARCHAR(255) and data with JSONB respectively.

Package Sidebar

Install

npm i pg-storage

Weekly Downloads

0

Version

1.1.3

License

ISC

Unpacked Size

14.8 kB

Total Files

15

Last publish

Collaborators

  • himanshu.mamgain