Socket
Socket
Sign inDemoInstall

redisk

Package Overview
Dependencies
36
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.4 to 2.1.5

8

CHANGELOG.md

@@ -7,2 +7,10 @@ ### Changelog

#### [v2.1.5](https://github.com/ArkerLabs/redisk/compare/v2.1.4...v2.1.5)
> 18 April 2020
- feat: 🎸 Now undefined values don't modify the persisted field [`997a1b9`](https://github.com/ArkerLabs/redisk/commit/997a1b92652b060a7967b190b4bafe7b3d869f63)
- chore: 🤖 Update to 2.1.5 [`f8b4f73`](https://github.com/ArkerLabs/redisk/commit/f8b4f730b92af2f433459e70458229914870375e)
- docs: ✏️ Update CHANGELOG [`42ac4b1`](https://github.com/ArkerLabs/redisk/commit/42ac4b13c9f27ddf9add86f6b238effcd6011f95)
#### [v2.1.4](https://github.com/ArkerLabs/redisk/compare/v2.1.3...v2.1.4)

@@ -9,0 +17,0 @@

3

dist/redisk.js

@@ -43,2 +43,5 @@ "use strict";

for (const property of Object.keys(properties).map(key => properties[key])) {
if (entity[property.name] === undefined) {
entity[property.name] = persistedEntity[property.name];
}
if (entity[property.name] !== persistedEntity[property.name]) {

@@ -45,0 +48,0 @@ changedFields.push(property.name);

2

package.json
{
"name": "redisk",
"version": "2.1.4",
"version": "2.1.5",
"description": "TypeScript ORM for Redis.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -246,2 +246,3 @@ <h1 align="center">

```
#### Note: Null fields will be removed from the persisted entity, undefined fields will not be modified from persisted entity.

@@ -248,0 +249,0 @@ ### Get by primary key

@@ -19,2 +19,5 @@ import { Entity } from '../../src/decorators/entity.decorator';

@Property()
public readonly description: string;
@Unique()

@@ -40,2 +43,3 @@ @Property()

name: string,
description: string,
email: string,

@@ -49,2 +53,3 @@ color: string,

this.name = name;
this.description = description;
this.email = email;

@@ -51,0 +56,0 @@ this.color = color;

@@ -5,7 +5,7 @@ import { User } from '../entities/user.entity';

export const users = [
new User('4409', 'John', 'john@email.com', 'red', 'tofu', groups[0], new Date('2020-02-22 10:00:00')),
new User('F8AC', 'Anthony', 'anthony@email.com', 'blue', 'avocado', groups[0], new Date('2020-02-22 12:34:00')),
new User('ACEF', 'Juan', 'juan@email.com', 'blue', 'tofu', null, new Date('2020-02-22 18:10:00')),
new User('A366', 'Jim', 'jim@email.com', 'blue', 'tofu', groups[1], new Date('2020-02-23 22:35:00')),
new User('D162', 'Rick', 'rick@email.com', 'red', 'rice', groups[1], new Date('2020-02-24 12:00:00')),
new User('4409', 'John', '', 'john@email.com', 'red', 'tofu', groups[0], new Date('2020-02-22 10:00:00')),
new User('F8AC', 'Anthony', '', 'anthony@email.com', 'blue', 'avocado', groups[0], new Date('2020-02-22 12:34:00')),
new User('ACEF', 'Juan', '', 'juan@email.com', 'blue', 'tofu', null, new Date('2020-02-22 18:10:00')),
new User('A366', 'Jim', '', 'jim@email.com', 'blue', 'tofu', groups[1], new Date('2020-02-23 22:35:00')),
new User('D162', 'Rick', '', 'rick@email.com', 'red', 'rice', groups[1], new Date('2020-02-24 12:00:00')),
];

@@ -27,2 +27,3 @@ import { RediskTestUtils } from './utils/redisk-test-utils';

const name = 'Anna';
const description = 'Description';
const email = 'anna@email.com';

@@ -36,3 +37,3 @@ const color = 'red';

it('should persist entity', async () => {
const user = new User(id, name, email, color, food, group, created);
const user = new User(id, name, description, email, color, food, group, created);

@@ -45,2 +46,3 @@ await utils.redisk.save(user);

name,
description,
email,

@@ -75,5 +77,5 @@ color,

it('should throw error', async () => {
const user = new User(id, name, email, color, food, null, created);
const user = new User(id, name, description, email, color, food, null, created);
await utils.redisk.save(user);
const user2 = new User('foo', name, email, color, food, null, created);
const user2 = new User('foo', name, description, email, color, food, null, created);
let exception;

@@ -92,3 +94,3 @@ try {

it('should update entities', async () => {
const user = new User(id, name, email, color, food, group, created);
const user = new User(id, name, description, email, color, food, group, created);
await utils.redisk.save(user);

@@ -102,3 +104,3 @@

const group2 = new Group(group.id, 'Foo');
const updatedUser = new User(id, newName, newEmail, newColor, food, group2, newCreated);
const updatedUser = new User(id, newName, description, newEmail, newColor, food, group2, newCreated);
await utils.redisk.save(updatedUser);

@@ -110,2 +112,3 @@

name: newName,
description,
email: newEmail,

@@ -140,5 +143,29 @@ color: newColor,

describe('Update persisted entity with undefineds', () => {
it('should ignore those properties', async () => {
const newName = 'Riley';
const user = new User(id, name, description, email, color, food, group, created);
await utils.redisk.save(user);
await utils.redisk.save(new User(id, newName, undefined, email, color, food, group, created));
const storedUser = await utils.redisk.getClient().hgetall('user:' + id);
expect(storedUser).toEqual({
id,
name: newName,
description,
email,
color,
food,
group: group.id,
created: String(created.valueOf()),
});
});
});
describe('Update persisted entity', () => {
it('should update entity', async () => {
const user = new User(id, name, email, color, food, group, created);
const user = new User(id, name, description, email, color, food, group, created);
await utils.redisk.save(user);

@@ -148,5 +175,6 @@

const newEmail = 'riley@email.com';
const newDescription = null;
const newColor = 'purple';
const newCreated = new Date('2020-03-25 12:10:04');
const updatedUser = new User(id, newName, newEmail, newColor, food, null, newCreated);
const updatedUser = new User(id, newName, newDescription, newEmail, newColor, food, null, newCreated);
await utils.redisk.save(updatedUser);

@@ -153,0 +181,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc