Comments (4)
So I did some research on this and it seems that the issue is getValue
.
var obj = { name: 'Steve',
age: 15,
features: { hair: 'brown', eyes: 'brown' } };
var key = 'features.hair';
_.result(obj, key); // undefined
from mingo.
I can hand roll a nested retrieval get/set but I filed another issue about replacing Underscore with Lodash (maybe in a v0.7.0) which would solve this issue.
from mingo.
You are right about the issue being getValue
. There is already an internal function which handles nested retrieval correctly called resolve
. However, that alone is not sufficient to address the problem. The root cause is that we resolve to the exact value of the given selector and not to the full object graph leading to the value.
For instance given the object
var obj = { "name": "Steve", "age": 15, "features": { "hair": "brown", "eyes": "brown" } };
Currently:
getValue(obj, "features.hair"); // undefined
resolve(obj, "features.hair"); // "brown"
We desire the full object graph leading to the value so that.
resolveObj(obj, "features.hair"); // {"features": {"hair": "brown"}}
I have a working fix for this at the moment, but I still need to do some extra to also handle dropping nested keys which will also not be working correctly.
Concerning lodash however I don't think we gain much switching. Even with their _.get
implementation, looking at the example in the docs shows that it is not consistent with MongoDB semantics as required by this project.
from mingo.
Fixed in v0.7.0
from mingo.
Related Issues (20)
- Possible breaking error in 6.1.1 `dateFromParts` HOT 1
- core.addOperators is missing HOT 1
- How does generator function for collection work? HOT 2
- Expressions in arithmetic operators are evaluated in a nested path HOT 2
- Projection not working properly for deep nested objects HOT 1
- $Reduce $Map Returning incorrect results and making other fields return undefined.
- Es6 Module build HOT 1
- [email protected] breaks CommonJS requires of files inside package HOT 20
- Issues with $let since 6.2.0 HOT 1
- Strange behaviour in $round HOT 3
- Wrong evaluation with `NaN` value HOT 4
- TypeError: CreateListFromArrayLike called on non-object HOT 10
- Filter inside of map causes undefined variable item error
- Add support for `$linearFill` (aggregation window)
- Add support for $fill (aggregation)
- Add support for $densify (aggregation)
- $filter "truthy" condition returns incorrect results HOT 4
- Support useStrictMode for all truth value checks HOT 1
- Add support for $graphLookup (pipeline)
- aggregate() $sort stage on nested date replaces all items in collection with the last item (6.3.2) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mingo.