Skip to content

Tallysticks/sequelize-enc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sequelize Enc

Support for encrypted attributes for Sequelize models.

Installation

npm install --save sequelize-enc

Usage

const Sequelize = require('sequelize')
const sequelizeEncPlugin = require('sequelize-enc')

const sequelize = new Sequelize()

sequelizeEncPlugin(sequelize, {
  encrypt: value => {
    return value
  },
  decrypt: value => {
    return value
  },
})

Example

const SampleModel = sequelize.define('SampleModel', {
  name: {
    type: Sequelize.STRING,
    allowNull: false,
  },
  details: {
    type: Sequelize.BLOB,
    encrypted: {
      type: Sequelize.JSONB,
    },
  },
})

await SampleModel.create({
  name: 'Sample name',
  details: {
    password: 'qwerty',
    secret: 'azerty',
  },
})

Releases

No releases published

Packages

No packages published