I am working on a Node application that does use multiple Mongoose database connections at once. I am separating the models set to each connection correctly and I am not saving any of the models in any parallel way that I could mess up. But I am getting a very strange result from Mongoose when it saves my model instance.
The line that kills:
> Model.create(data, function(err, model) {...})
[I have written this in the shorthand method, but any way I try to write it, I get the exact same problem regardless.]
The result I get:
The model IS saved to the database exactly as you would expect; I can open `mongo`, navigate to the db, and the model instance's data will be there. But inside of my JavaScript, the internal save() method is not calling the callback I have supplied it. I have looked at all of my code: the connection is correct (because the data is being saved correctly), the callback is a function (I wrapped it in a closure that returns it as a function and I know it is a function), the data being saved is correct (so says the DB and console.log), my schema with provided data validates correctly (I ran the model instance through the #validate method and err was undefined). I have no idea what the problem could be.
I have looked online at every resource that deals with this problem (and the StackOverflow questions answered on the subject). I have found no solution.
Worst Case Scenario: I'll have to use the hacky setTimeout method of waiting for the model to be saved to the DB and then, since it does actually save, I will have to find it via querying and work with the instance from there. There is a lot of headway and potholes in that option, please help me resolve this problem.