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

input id to findOrCreate and it will not return a new model if the id dosen't exist #399

Closed
xcooper opened this issue Sep 6, 2013 · 1 comment

Comments

@xcooper
Copy link

xcooper commented Sep 6, 2013

code

I input an id to findOrCreate function, and it just not return a new created model as I expected. After tracing code, I found that at line 1702, it will not create a model if I don't provide a object as first argument. Would you please fix this for me? Or this is OK for some reason?

@PaulUithol
Copy link
Owner

Sorry, but that's not possible. findOrCreate is used a lot on data coming straight from the server, where we really don't want a lot of placeholder models to be created where we just get a bunch of ids. Looks like this part isn't clear in the docs though; I'll try to clarify it.

nl0 added a commit to nl0/Backbone-relational that referenced this issue Feb 25, 2014
* upstream/master: (35 commits)
  Upgrade qunit
  Fix subModels not being populated properly on Underscore 1.6.0, due to `_.each` api change.
  Fire change events right away if we're not in a nested scenario. Fixes PaulUithol#427
  Document `store.unregister`
  `store.unregister` now also accepts collections or a model type
  Change `findOrCreate` to pass `parsedAttributes` to `build`, and adjust tests to reflect change.
  Remove unnecessary locking
  Update change log
  Add test for models not being added to store until they get an id
  Change where we listen to `relational:unregister`.
  Only add models with an id to the store. Closes PaulUithol#411
  Fix a bug in the (crude) performance test
  Add a small test for `clear`
  Fix collection return values when setting/removing `[]` and `null`. Ref PaulUithol#419
  Clarify the behavior of `findOrCreate` when it just a receives a scalar value. Ref PaulUithol#399
  Proper return values on collection methods for Backbone 1.1. Closes PaulUithol#419
  Submodels: accommodate multiple 'type' keys for the same submodel. Closes PaulUithol#429
  Hmm, fix spaces/tabs mix in the example
  Update a few version numbers in the docs to 0.8.7
  Backbone-relational 0.8.7
  ...
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

No branches or pull requests

2 participants