Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not modify opts in base.js, these may be globals. #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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