3.0.17 • Published 5 years ago

@knetik/micro-postgres v3.0.17

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

Knetik Micro Postgres

This package adds postgres support using sequelize to any micro-core application as a multi tenant adaptor.

When a customer connects to a micro-core application, the required app_id is passed into the postgres initializer and used as the database name. Then creating a connection and loading any sequelize models defined in the models directory.

Example Usage

In app/models/example.postgres.js

const Sequelize = require('sequelize');

module.exports = (sequelize) => {
  return sequelize.define('example', {
    prop: {
      type: Sequelize.NUMBER
    }
  },
  {
    timestamps  : true,
    underscored : true
  });
}

In micro-console

App.connect(app_id, access_token)
.then(App => App.Postgres.get('Example'))
.then(Example => Example.create({ prop: 42 }))
.then(res => console.log(res))
.catch(err => console.log(err))

In a micro-core module

module.exports (App) => {
  cosnt Example = App.Postgres.get('Exmaple')
  Example.create({ prop: 42 })
}

Migrations

Migrations are handled with umzug: https://github.com/sequelize/umzug

  1. Add migrations to APP_ROOT/db/migrations
  2. Migration status will be checked on each request.
  3. If there are pending migrations, they will be run and then the status will be cached in the mc_internal_metadata table per client.

Feel free to add migration hook into your deploy tooling.

3.0.17

5 years ago

3.0.16

5 years ago

3.0.15

5 years ago

3.0.14

5 years ago

3.0.13

5 years ago

3.0.12

5 years ago

3.0.11

5 years ago

3.0.10

5 years ago

3.0.9

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.24

5 years ago

2.0.23

5 years ago

2.0.22

5 years ago

2.0.21

5 years ago

2.0.20

5 years ago

2.0.19

5 years ago

2.0.18

5 years ago

2.0.17

5 years ago

2.0.16

5 years ago

2.0.15

5 years ago

2.0.14

5 years ago

2.0.13

5 years ago

2.0.12

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago