drudge/mongoose-findorcreate — pull request #2 by joscha (2012-12-05 19:37:29+00:00)
Title: Fix creation of new documents

When using nested schemas (e.g. {a:{id: ...}) and a condition part is nested, then the doc gets overwritten, e.g.

```
doc = { a: { b: 1, c: 2} }
condition = {a: {b: 1}}
```

results in `doc == condition`, because `doc[a]` gets replaced with `condition[a]`.

In `jamplify/supergoose` this was forked from, it was the different way round, conditions get extended by doc, so the loop is actually the wrong way around and the earlier commit to save the doc was only a partial fix.