Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/lokijs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
return clone(obj, 'shallow');
}

function splitPath(path){
const result=path.split(/\.+(?![^\<]*\>)/)
return result.map(item=> item.replace(/\<|\>/g,''))
}

var Utils = {
copyProperties: function (src, dest) {
var prop;
Expand Down Expand Up @@ -384,7 +389,7 @@
prop = properties[i];
field = prop[0];
if (~field.indexOf('.')) {
arr = field.split('.');
arr = splitPath(field),//**field.split('.');
val1 = Utils.getIn(obj1, arr, true);
val2 = Utils.getIn(obj2, arr, true);
} else {
Expand Down Expand Up @@ -596,7 +601,7 @@
}

if (property.indexOf('.') !== -1) {
return dotSubScan(item, property.split('.'), doQueryOp, b[property], item);
return dotSubScan(item, splitPath(property), doQueryOp, b[property], item);
}
return doQueryOp(item[property], filter, item);
});
Expand Down Expand Up @@ -3306,7 +3311,7 @@
var val1, val2, arr;
return function (a, b) {
if (~prop.indexOf('.')) {
arr = prop.split('.');
arr = splitPath(prop);
val1 = Utils.getIn(data[a], arr, true);
val2 = Utils.getIn(data[b], arr, true);
} else {
Expand Down Expand Up @@ -3605,7 +3610,7 @@

// currently supporting dot notation for non-indexed conditions only
if (usingDotNotation) {
property = property.split('.');
property = splitPath(property);
for (i = 0; i < len; i++) {
rowIdx = filter[i];
record = t[rowIdx];
Expand Down Expand Up @@ -3638,7 +3643,7 @@
len = t.length;

if (usingDotNotation) {
property = property.split('.');
property = splitPath(property);
for (i = 0; i < len; i++) {
record = t[i];
if (dotSubScan(record, property, fun, value, record)) {
Expand Down Expand Up @@ -5482,7 +5487,7 @@
var wrappedComparer =
(function (prop, data) {
var val1, val2;
var propPath = ~prop.indexOf('.') ? prop.split('.') : false;
var propPath = ~prop.indexOf('.') ?splitPath(prop) : false;
return function (a, b) {
if (propPath) {
val1 = Utils.getIn(data[a], propPath, true);
Expand Down Expand Up @@ -7487,7 +7492,7 @@
// pass without processing
return obj[property];
}
var pieces = property.split('.'),
var pieces = splitPath(property)
root = obj;
while (pieces.length > 0) {
root = root[pieces.shift()];
Expand Down