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.

_markModified is not a function

See original GitHub issue

Was getting the following error after upgrading to latest mongoose:

\node_modules\mongoose\lib\types\embedded.js:68
    this.__parentArray._markModified();
                       ^
TypeError: undefined is not a function
    at EmbeddedDocument.markModified (\node_modules\mongoose\lib\types\embedded.js:68:24)
    at SchemaArray.cast (\node_modules\mongoose\lib\schema\array.js:180:9)
    at SchemaArray.SchemaType.getDefault (\node_modules\mongoose\lib\schematype.js:587:23)
    at EmbeddedDocument.Document.$__buildDoc (\node_modules\mongoose\lib\document.js:243:22)
    at EmbeddedDocument.Document (\node_modules\mongoose\lib\document.js:61:20)
    at new EmbeddedDocument (\node_modules\mongoose\lib\types\embedded.js:30:12)
    at EmbeddedDocument (\node_modules\mongoose\lib\schema\documentarray.js:27:17)
    at DocumentArray.SchemaArray (\node_modules\mongoose\lib\schema\array.js:61:21)
    at new DocumentArray (\node_modules\mongoose\lib\schema\documentarray.js:46:13)
    at Function.Schema.interpretAsType (\node_modules\mongoose\lib\schema.js:582:14)
    at Schema.path (\node_modules\mongoose\lib\schema.js:527:29)
    at Schema.add (\node_modules\mongoose\lib\schema.js:411:12)
    at new Schema (\node_modules\mongoose\lib\schema.js:98:10)
    at Object.<anonymous> (\modules\project\server\models\project.server.model.js:71:21)
    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 \config\lib\mongoose.js:15:5
    at Array.forEach (native)

Changing

EmbeddedDocument.prototype.markModified = function(path) {
  this.$__.activePaths.modify(path);
  if (!this.__parentArray) {
    return;
  }

to

EmbeddedDocument.prototype.markModified = function(path) {
  this.$__.activePaths.modify(path);
  if (!this.__parentArray || !this.__parentArray._markModified) {
    return;
  }

on node_modules\mongoose\lib\types\embedded.js seems to do the trick

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:13

github_iconTop GitHub Comments

1reaction
rubenstolkcommented, Mar 6, 2017

@vkarpov15 can’t say exactly anymore, happened in the “hydration” from json to models with subdocuments.

0reactions
vkarpov15commented, Nov 16, 2018

@ashishdommety can you please open up a separate issue with code samples?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding markModified() in Mongoose
By default, mongoose would not persists the change of mixed array columns ... mongoose calls the $__handleSave() function from $__save() and ...
Read more >
Mongo/Mongoose - markModified not working - Stack Overflow
When I log the doc inside the .save function it appears to have saved successfully. However on querying the db elsewhere the save...
Read more >
Mongoose v6.8.1: Document
[fn] «Function». Initializes the document without setters or marking anything modified. Called internally after a document is returned from mongodb. Normally, ...
Read more >
Mongo/Mongoose - markModified not working-mongodb
When I log the doc inside the .save function it appears to have saved successfully. However on querying the db elsewhere the save...
Read more >
Scripting API: Mesh.MarkModified - Unity - Manual
A manual call to MarkModified can be used later to notify the dependent renderer components of a mesh geometry change. MarkModified function only...
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