Giter Club home page Giter Club logo

Comments (4)

whitfin avatar whitfin commented on June 19, 2024

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.

whitfin avatar whitfin commented on June 19, 2024

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.

kofrasa avatar kofrasa commented on June 19, 2024

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.

kofrasa avatar kofrasa commented on June 19, 2024

Fixed in v0.7.0

from mingo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.