Socket
Socket
Sign inDemoInstall

redux-orm

Package Overview
Dependencies
1
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.19 to 0.1.20

25

lib/Model.js

@@ -185,3 +185,3 @@ 'use strict';

* Records a update to the {@link Model} instance for multiple field value assignments.
* @param {Object} mergeObj - an object that will be merged with this instance.
* @param {Object} userMergeObj - an object that will be merged with this instance.
* @return {undefined}

@@ -191,3 +191,24 @@ */

key: 'update',
value: function update(mergeObj) {
value: function update(userMergeObj) {
var relFields = this.getClass().fields;
var mergeObj = Object.assign({}, userMergeObj);
// If an array of entities or id's is supplied for a
// many-to-many related field, clear the old relations
// and add the new ones.
for (var mergeKey in mergeObj) {
if (relFields.hasOwnProperty(mergeKey)) {
var field = relFields[mergeKey];
if (field instanceof _fields.ManyToMany) {
var _mergeKey;
// TODO: instead of clearing the old records,
// we should check which ones can remain.
this[mergeKey].clear();
(_mergeKey = this[mergeKey]).add.apply(_mergeKey, _toConsumableArray(mergeObj[mergeKey]));
delete mergeObj[mergeKey];
}
}
}
this.getClass().addUpdate({

@@ -194,0 +215,0 @@ type: _constants.UPDATE,

3

lib/test/testSchema.js

@@ -469,5 +469,4 @@ 'use strict';

Book.withId(0)['delete']();
Book.withId(1).genres.add(1, g3);
Book.withId(1).update({ genres: [1, g3] });
var nextState = session.reduce();
(0, _chai.expect)(nextState.BookGenres.items).to.have.length(2);

@@ -474,0 +473,0 @@ (0, _chai.expect)(nextState.BookGenres.items).to.deep.equal([2, 3]);

{
"name": "redux-orm",
"version": "0.1.19",
"version": "0.1.20",
"description": "Simple ORM to manage and query your state trees",

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

@@ -493,6 +493,25 @@ import forOwn from 'lodash/object/forOwn';

* Records a update to the {@link Model} instance for multiple field value assignments.
* @param {Object} mergeObj - an object that will be merged with this instance.
* @param {Object} userMergeObj - an object that will be merged with this instance.
* @return {undefined}
*/
update(mergeObj) {
update(userMergeObj) {
const relFields = this.getClass().fields;
const mergeObj = Object.assign({}, userMergeObj);
// If an array of entities or id's is supplied for a
// many-to-many related field, clear the old relations
// and add the new ones.
for (const mergeKey in mergeObj) {
if (relFields.hasOwnProperty(mergeKey)) {
const field = relFields[mergeKey];
if (field instanceof ManyToMany) {
// TODO: instead of clearing the old records,
// we should check which ones can remain.
this[mergeKey].clear();
this[mergeKey].add(...mergeObj[mergeKey]);
delete mergeObj[mergeKey];
}
}
}
this.getClass().addUpdate({

@@ -499,0 +518,0 @@ type: UPDATE,

@@ -316,5 +316,4 @@ import {expect} from 'chai';

Book.withId(0).delete();
Book.withId(1).genres.add(1, g3);
Book.withId(1).update({genres: [1, g3]});
const nextState = session.reduce();
expect(nextState.BookGenres.items).to.have.length(2);

@@ -321,0 +320,0 @@ expect(nextState.BookGenres.items).to.deep.equal([2, 3]);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc