Skip to content

Conversation

@toots
Copy link

@toots toots commented Jan 23, 2012

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..

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant