SHARE
TWEET

Untitled

a guest Oct 14th, 2019 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { Sequelize, Model, DataTypes } = require('sequelize');
  2. const uuidv4 = require('uuid/v4');
  3.  
  4. const sequelize = new Sequelize({
  5.   dialect: 'sqlite',
  6.   storage: 'db.sqlite'
  7. });
  8.  
  9. sequelize
  10.   .authenticate()
  11.   .then(() => {
  12.     console.log('Connection has been established successfully.');
  13.   })
  14.   .catch(err => {
  15.     console.error('Unable to connect to the database:', err);
  16.   });
  17.  
  18. class Session extends Model { }
  19.  
  20. Session.init({
  21.   token: { type: DataTypes.UUIDV4, allowNull: false, defaultValue: uuidv4 },
  22.   params: { type: DataTypes.JSON, allowNull: false, defaultValue: {} }
  23. }, { sequelize, modelName: 'session' });
  24.  
  25. Session.sync({ force: true });
  26.  
  27. module.exports = {
  28.   Session
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top