Map finds as well as updates #23

merged 4 commits into from Jul 13, 2011


None yet

2 participants


Avoids casting to ObjectId manually all the time.

Rob Holland added some commits Jul 7, 2011
Rob Holland Correct typo. d910a81
Rob Holland Automatically map array fields. 4041c0b
Rob Holland Map finds as well as updates.
Avoids having to cast things to ObjectId all the time by hand.
Rob Holland Map the find criteria in updates as well as the update criteria. c9c0efd

not sure 100% about this, but the commit is good and tested so I will release it and see how works on production :)


can you explain this? I don't understand


It stops me having to pass ObjectID around inside my applications all the time, because I can use maps to cast it inside the model logic.

I then no longer need to do:

MyModel.mongo('find', { _id: ObjectID( }, ...)

I can just pass directly.

@masylum masylum merged commit 4b9724b into masylum:master Jul 13, 2011

I will push this to npm once I have some tests written.

Looks good, but not sure if any side effect may occur.
We could also provide a default _id -> ObjectId mapping.


The default mapping would be good, that's the main reason I did it. It would need to catch fields named _id at all levels though. It would also have to be optional, not everyone will use ObejctId for _id presumably.


Is already pushed at npm. I didn't include the default mapping though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment