3.6.1 • Published 2 years ago

jovo-db-postgresql v3.6.1

Weekly downloads
48
License
Apache-2.0
Repository
-
Last release
2 years ago

PostgreSQL Database Integration

To view this page on the Jovo website, visit https://v3.jovo.tech/marketplace/jovo-db-postgresql

Learn how to use PostgreSQL as your app's database to store user specific data.

Installation

Download the package like this:

$ npm install --save jovo-db-postgresql

PostgreSQL database integration can be enabled in the src/app.js file like this:

// @language=javascript

// src/app.js

const { PostgreSQL } = require('jovo-db-postgresql');

// Enable DB after app initialization
app.use(new PostgreSQL());

// @language=typescript

// src/app.ts

import { PostgreSQL } from 'jovo-db-postgresql';

// Enable DB after app initialization
app.use(new PostgreSQL());

In your config.js file, you can set the db configuration like this:

// @language=javascript

// src/config.js

module.exports = {
  db: {
    PostgreSQL: {
      tableName: 'yourTableName',
      connection: {
        host: '',
        port: 3000,
        user: '',
        password: '',
        database: '',
      },
    },
  },

  // ...
};

// @language=typescript

// src/config.ts

const config = {
  db: {
    PostgreSQL: {
      tableName: 'yourTableName',
      connection: {
        host: '',
        port: 3000,
        user: '',
        password: '',
        database: '',
      },
    },
  },

  // ...
};

This is the default configuration for PostgreSQL, if not specified otherwise:

// @language=javascript

// src/config.js

module.exports = {
  db: {
    PostgreSQL: {
      tableName: 'users',
      primaryKeyColumn: 'userId',
      dataColumnName: 'userData',
      connection: {},
    },
  },

  // ...
};

// @language=typescript

// src/config.ts

const config = {
  db: {
    PostgreSQL: {
      tableName: 'users',
      primaryKeyColumn: 'userId',
      dataColumnName: 'userData',
      connection: {},
    },
  },

  // ...
};

Once the configuration is done, the PostgreSQL database integration will create a table in your Database on the first read/write attempt.

3.6.1

2 years ago

3.6.0

2 years ago

3.5.1

3 years ago

3.5.0

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago