@24hr/seqcryptor
Advanced tools
+1
-1
| { | ||
| "name": "@24hr/seqcryptor", | ||
| "version": "0.8.10", | ||
| "version": "0.8.11", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -66,3 +66,3 @@ import { DataTypes, Model, Sequelize } from 'sequelize'; | ||
| it('Can set null to a jsonb even if a default value but allownull is true', async () => { | ||
| it('Can set null to a jsonb if allownull is true', async () => { | ||
@@ -72,3 +72,4 @@ const encryptor = seqCryptor('_SUPER_SECRET_KEY_WITH_32_BYTES_'); | ||
| class User extends Model { | ||
| public info!: any; | ||
| public info!: any | null; | ||
| public info2!: any | null; | ||
| public data!: any; | ||
@@ -86,6 +87,10 @@ public guid!: string; | ||
| info: encryptor({ | ||
| allowNull: true, | ||
| type: DataTypes.JSONB, | ||
| field: 'info', | ||
| defaultValue: {}, | ||
| }), | ||
| info2: encryptor({ | ||
| allowNull: true, | ||
| type: DataTypes.JSONB, | ||
| field: 'info2', | ||
| }), | ||
@@ -105,6 +110,18 @@ data: encryptor({ | ||
| const user = await User.create({ info: null, data: { foo: 1 }, name: 'bar' }); | ||
| const userParsed = await User.findOne({ where: { guid: user.guid } }); | ||
| expect(userParsed!.info).toEqual(null); | ||
| const data: any = {}; | ||
| const payload = { | ||
| data: { | ||
| foo: 1, | ||
| }, | ||
| name: 'bar', | ||
| info: data.info, | ||
| }; | ||
| const user2 = await User.create(payload); | ||
| const userParsed2 = await User.findOne({ where: { guid: user2.guid } }); | ||
| expect(userParsed2!.info).toEqual(null); | ||
| expect(userParsed2!.info2).toEqual(null); | ||
| }); | ||
@@ -111,0 +128,0 @@ |
36832
1.51%760
2.29%