didit-tech/FastLegS — pull request #30 by toots (2012-01-23 08:46:25+00:00)
Title: Do not modify opts in base.js, these may be globals.

Modifying options passed to `findOne` and the like can be potentially dangerous. Here's an example:

# What to fetch for a radio
radiosParams =
order : [ "name" ]
only : [
"id", "name", "token", "website",
"title", "artist", "genre", "description",
"longitude", "latitude"
]
include : {
streams : {
only : [ "id", "format", "url", "msg" ]
}
}

@ Wrappers
getRadios = (param, fn) ->
Radio.find param, radiosParams, fn

getRadio = (param, fn) ->
Radio.findOne param, radiosParams, fn

In one call `getRadio` then all subsequent calls to `getRadios` have only one result, due to the fact that `limit: 1` gets added to `radiosParams`..