Socket
Socket
Sign inDemoInstall

redux-orm

Package Overview
Dependencies
Maintainers
4
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-orm - npm Package Compare versions

Comparing version 0.13.0 to 0.13.1

6

CHANGELOG.md
**Minor changes before v1.0.0 can include breaking changes.**
### 0.13.0
* Automatically index foreign keys. Queries will be fulfilled by using foreign key indexes if possible. Only works for direct FK relationships. For instance, `book.authors` will be optimized if the `Author` model has a `fk({ to: 'Book', 'relatedName': 'authors' })` field. ([#250](https://github.com/tommikaikkonen/redux-orm/pull/250), [b9c1635](https://github.com/tommikaikkonen/redux-orm/commit/b9c16359f018dacfaaea8b5450693eea3263ffe9))
This release should be non-breaking, however it does slightly decrease performance of writes. Many-to-many queries (e.g. `child.parents`) are also less performant, but in theory it is now possible to optimize them by an order of magnitude (similar to SQL joins).
### 0.12.4

@@ -4,0 +10,0 @@

25

es/db/Table.js
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _typeof from "@babel/runtime/helpers/typeof";
import _objectSpread from "@babel/runtime/helpers/objectSpread";

@@ -192,5 +193,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

if (type === FILTER) {
if (type === FILTER && _typeof(payload) === 'object') {
var indexes = Object.entries(branch.indexes);
var accessedIndexes = [];
var indexAttrs = [];
indexes.forEach(function (_ref) {

@@ -208,2 +210,3 @@ var _ref2 = _slicedToArray(_ref, 2),

accessedIndexes.push(index[payload[attr]]);
indexAttrs.push(attr);
}

@@ -223,3 +226,21 @@ }

}, lastIndex);
return reducer(_this2.accessIds(branch, indexedIds), clause);
var newPayload = Object.keys(payload).reduce(function (withoutIndexAttrs, filterAttr) {
if (!indexAttrs.includes(filterAttr)) {
withoutIndexAttrs[filterAttr] = payload[filterAttr];
}
return withoutIndexAttrs;
}, {});
if (Object.keys(newPayload).length === 0) {
/**
* No need to filter these rows any further.
* The used indexes satisfy this clause's conditions.
*/
return _this2.accessIds(branch, indexedIds);
}
return reducer(_this2.accessIds(branch, indexedIds), _objectSpread({}, clause, {
payload: newPayload
}));
}

@@ -226,0 +247,0 @@ } // Give up optimization: Retrieve all rows (full table scan).

@@ -12,2 +12,4 @@ "use strict";

var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _objectSpread5 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));

@@ -213,5 +215,6 @@

if (type === _constants.FILTER) {
if (type === _constants.FILTER && (0, _typeof2.default)(payload) === 'object') {
var indexes = Object.entries(branch.indexes);
var accessedIndexes = [];
var indexAttrs = [];
indexes.forEach(function (_ref) {

@@ -229,2 +232,3 @@ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),

accessedIndexes.push(index[payload[attr]]);
indexAttrs.push(attr);
}

@@ -244,3 +248,21 @@ }

}, lastIndex);
return reducer(_this2.accessIds(branch, indexedIds), clause);
var newPayload = Object.keys(payload).reduce(function (withoutIndexAttrs, filterAttr) {
if (!indexAttrs.includes(filterAttr)) {
withoutIndexAttrs[filterAttr] = payload[filterAttr];
}
return withoutIndexAttrs;
}, {});
if (Object.keys(newPayload).length === 0) {
/**
* No need to filter these rows any further.
* The used indexes satisfy this clause's conditions.
*/
return _this2.accessIds(branch, indexedIds);
}
return reducer(_this2.accessIds(branch, indexedIds), (0, _objectSpread5.default)({}, clause, {
payload: newPayload
}));
}

@@ -247,0 +269,0 @@ } // Give up optimization: Retrieve all rows (full table scan).

8

package.json
{
"name": "redux-orm",
"version": "0.13.0",
"version": "0.13.1",
"description": "Simple ORM to manage and query your state trees",

@@ -15,4 +15,4 @@ "main": "lib/index.js",

"prepublishOnly": "npm run build",
"transpile:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir lib",
"transpile:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"transpile:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir lib --ignore */test",
"transpile:es": "cross-env BABEL_ENV=es babel src --out-dir es --ignore */test",
"build:umd": "webpack --config webpack.dev.js",

@@ -25,3 +25,3 @@ "build:umd:min": "webpack --config webpack.prod.js",

"deploydocs": "npm run build && gulp deploy",
"clean": "rimraf lib dist docs"
"clean": "rimraf lib es dist docs coverage"
},

@@ -28,0 +28,0 @@ "keywords": [

@@ -184,5 +184,6 @@ import reject from 'lodash/reject';

}
if (type === FILTER) {
if (type === FILTER && typeof payload === 'object') {
const indexes = Object.entries(branch.indexes);
const accessedIndexes = [];
const indexAttrs = [];
indexes.forEach(([attr, index]) => {

@@ -196,2 +197,3 @@ if (clauseFiltersByAttribute(clause, attr)) {

accessedIndexes.push(index[payload[attr]]);
indexAttrs.push(attr);
}

@@ -210,3 +212,20 @@ }

}, lastIndex);
return reducer(this.accessIds(branch, indexedIds), clause);
const newPayload = Object.keys(payload)
.reduce((withoutIndexAttrs, filterAttr) => {
if (!indexAttrs.includes(filterAttr)) {
withoutIndexAttrs[filterAttr] = payload[filterAttr];
}
return withoutIndexAttrs;
}, {});
if (Object.keys(newPayload).length === 0) {
/**
* No need to filter these rows any further.
* The used indexes satisfy this clause's conditions.
*/
return this.accessIds(branch, indexedIds);
}
return reducer(this.accessIds(branch, indexedIds), {
...clause,
payload: newPayload,
});
}

@@ -213,0 +232,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc