New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

pg-storage

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-storage

PostgreSQL storage option for the Microsoft Bot Framework

latest
npmnpm
Version
1.1.3
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

botbuilder

FAQs

Package last updated on 25 Oct 2023

Related posts