Initialize the database connection, connects models to Sequelize and syncs them

Parameters:
NameTypeAttributesDescription
modelsarray

An array that contains Sequelize models

associationsobject<optional>

An object mapping associations between models

Properties
NameTypeAttributesDescription
oneToOnearray<optional>

An array containing an array with oneToOne associations

oneToManyarray<optional>

An array containing an array with oneToMany associations

syncboolean<optional>

Sync models to database on initialize

Since
  • 2.2.0
Author
  • Glenn de Haan
Returns:
Type: 
Promise.<void>
Example
const {Runtime, db} = require('@neobeach/core');

const User = require('./models/User');

Runtime(async () => {
   // Include your own code here
   await db.init([User]);
});