Giter Site home page Giter Site logo

Comments (7)

mccormicka avatar mccormicka commented on August 21, 2024

Hi @janek-bieser,
I have never tried to use populate with mockgoose.
I will look into this.
Thanks

from mockgoose.

yads avatar yads commented on August 21, 2024

We're having the same issue.

from mockgoose.

yads avatar yads commented on August 21, 2024

I may have tracked down the issue. When items are fetched in Mockgoose it uses _.clone to clone the item. However, nested objects don't get cloned and get assigned by reference. So when the populate goes in and updates the populated values, it's doing it on the references not the cloned values.

There needs to be some sort of recursive cloning since there is some custom logic re ObjectIds.

Edit: I think I have a fix for this issue, i'll test it some more and try to get it up tonight.

from mockgoose.

mypark avatar mypark commented on August 21, 2024

HI - any updates on the open pull request? I wanted to get the populate() function working on my unit tests and would be great if this solved the populate issue.

from mockgoose.

mypark avatar mypark commented on August 21, 2024

@yads so it looks like your fix works if you don't pass any select fields to the populate, but if you do it runs into the same issue .. e.g. .populate('createdBy', {fname:1, lname:1});

from mockgoose.

ovaris avatar ovaris commented on August 21, 2024

It would be really really cool to have this fixed!

from mockgoose.

winfinit avatar winfinit commented on August 21, 2024

pull request was merged and new 2.0.2 version in now on npm, thank you for your change.

from mockgoose.

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.