pg-storage
v1.1.3
Published
PostgreSQL storage option for the Microsoft Bot Framework
Maintainers
Readme
Bot Builder PostgreSQL Storage
This is a simple storage adapter for PostgreSQL.
Installation
npm install pg-storage --saveUsage
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
PostgreSQLOptionsthat is passed to thePostgreSQLStorageobject extends theconfigobject of that package. All options from thatconfigoption can be passed in.
This module assumes two columns in your database table:
idwith datatypeVARCHAR(255)anddatawithJSONBrespectively.
