LearnBoost/mongoose — Issue #673: Spontaneous Data Deletion
Author: ProjectMoon
Created: 2012-01-06 17:41:02+00:00
State: open

I have a very odd problem, and I'm still not entirely sure if it's a problem in my code or mongoose. I'm working on a MUD server, and I've got it to the point where a world can be loaded into a Mongo database via Mongoose, and then loaded to be wandered around in.

The rooms are loaded from the database into memory, and stored in an associative array (made with `{}`). There is no other direct interaction with mongoose. However, when I move into another room, the data for the room in MongoDB simply disappears. There's no exception, no mongoose error that I'm aware of. I just move, and the data goes poof. It's still in memory of course, and I can move around the MUD until I restart it, at which point crashes because there's no world data.

The MUD code is located here: https://github.com/ProjectMoon/nmud

Steps to reproduce:

```
cd nmud
node import.js ./sampleworld.json
node main.js

nmud> move north
nmud> move south
```

When you move into the room, the data for it disappears from the `rooms` collection in the nmud database in Mongo.

I've stepped through my code with a debugger, and the room data is there from the command being entered and the results of the command being output, so I'm not really sure where it's happening. I suspect it's somewhere inside MongoDB.

Is there a way to turn on detailed logging for Mongoose? That would help me better identify the problem. It would also help me produce a boiled-down test case.

The MUD server does some really weird stuff with mixins and prototype chains (see core.js), and I highly suspect this is causing issues with Mongoose. Not sure though.