question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_.cloneDeep with sequelize object

See original GitHub issue

Hi,

I’m trying to _.cloneDeep the sequelize object and receive the next:

Unhandled rejection Error: Cannot find module 'pg-native'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/pavelp/Sites/xxx/node_modules/pg/lib/native/index.js:1:76)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at null.<anonymous> (/Users/pavelp/Sites/xxx/node_modules/pg/lib/index.js:78:36)
    at forOwn (/Users/pavelp/Sites/xxx/node_modules/lodash/dist/lodash.js:2105:32)
    at baseClone (/Users/pavelp/Sites/xxx/node_modules/lodash/dist/lodash.js:816:33)
    at /Users/pavelp/Sites/xxx/node_modules/lodash/dist/lodash.js:817:23
    at forOwn (/Users/pavelp/Sites/xxx/node_modules/lodash/dist/lodash.js:2105:15)

Thought it has something in common with https://github.com/sequelize/sequelize/issues/3781 , but I’ve updated the sequelize to 3.2.0 and the issue is still there.

Any hint if it is something I can fix?

Regards,

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
PavelPolyakovcommented, Jun 10, 2015

For those who might me interested.

for me it was enough to do the next:

        // clone, so we don't tounch the original values
        data = _.cloneDeep(data, function (value) {
            // specially for the sequelize instances
            if (value && value.toJSON) {
                return value.toJSON();
            }
        });
0reactions
PavelPolyakovcommented, Jun 10, 2015

@mickhansen

Thanks,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deep copy Node JS object without reference - Stack Overflow
_.clone only creates a shallow clone of the Object. Try _.cloneDeep .
Read more >
Methods for deep cloning objects in JavaScript - LogRocket Blog
There are several ways to shallow clone objects in JavaScript, but deep cloning objects is trickier. We highlight several methods to do so....
Read more >
How Deep Cloning Objects in JavaScript Works - DigitalOcean
A quick breakdown on how to clone an object in JavaScript the right way through deep cloning using Lodash.
Read more >
node-npmtest-sequelize/sequelize/lib/ » sequelize.js
See sequelize.define for options * @param {Object} ... cloneDeep(globalOptions.define), options); } options = Utils.merge({ name: { plural: ...
Read more >
Possible to use one model on clones of a table?
Where each table is just a clone of the original model. Is there any way I can create just one Sequelize model where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found