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, PostgreSQLOptions } from 'pg-storage';
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.