javascript - mongoose .save() hangs with 3 level of subdocuments when called from node.js -


I am currently working with Mongoose and Node.JS.

I am using these schemas, this question):

  var gameSchema = new schema ({game id: {number:}}, round: [round. Schema]}); Var roundSchema = new schema ({roundId: {type: number}, rows: [Line.schema]}, {_id: false}); Var lineSchema = new schema ({lineId: {type: number} plays: [Play.schema]}, {_id: false}); Var playSchema = New schema ({Category: {type: string}, Score: {type: number}}, {_id: false});  

For the first time, I get a goal together with one goal, and after that some characteristics are changed and the score is pushed with many plays. When I try

  game.save (function (err) {console.log ("save it"); if (! Mistake) {console.log ('ok') ;} And {console.log ('error:' + error);}}});  

The server is just hanging and does nothing, none of the console messages print. Seeing the Mongoose Lodge, I could not find an error message or some logs helped me.

The strange thing is that if I change the array with an empty [] play, hope is there.

Here is an example of a game document which I am trying to save:

  {__v: 1, _id: 53d427c43ff7f8bc1b9aa3b6, game id: 1, round: [ {RoundId: 1, lines: [{line: 1: 1, plays: [{Score: 10, category: 'color'}, {Score: 10, category: 'animalless'}}}}}}}} Code> 

Any thoughts?

Thank you!

After entering my head in the wall after days and days, I thought what was my problem.

My "Placekema" was a method definition, this method was called valid .

PlaySchema.method.validate

was the method that was preventing my play from ing saved to database once I compared that method name to "valid" Something else changed in, it worked fine. It seems that Mongo considers "valid" as a reserved word.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -