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
Collection.fetch() doesn't yield any results.. #60
Comments
Adding something like the following to line 157 in sql.js makes the fetch work: if (_.has(opts, 'success')) opts.success(model.models); But as I said, I have no idea on how you want all this to work together so this is just a quick fix for me to be able to use the DB at all util the real fix gets done.. ;-) |
@hedlund Thanks for the heads up. I'll be working with the sql adapter this week. I'll take a look fetching collections and your fix. I'll keep you posted. We are missing to tracking issues in Jira so the community can see the progress. That should happen in the next day or so. The Jira ticket is ALOY-234. |
@mtnlife999 Sounds great! :-) If I could pitch in another wish it would be to extend the Backbone Collections object with functionality to do bulk operations, e.g. updating & destroying mutiple models at the same time (using filters or something similar). The Backbone models & collections have been modeled around a REST interface so they don't want that type of thing in the library, but doing as much as possible in as few transactions as possible is best practice for Titanium, so there is a difference in approach here that needs to be addressed.. :-) |
@hedlund: I'm using the app in test/apps/sql_model and fetching a collection is working. For example after adding and saving book models I can do a books.fetch(); I see in the sql adapter at line 157 that the fetch event is fired. Could it be that you did not bind the collection to the fetch event? For example in the books sample app books.bind("fetch", function() {...}; Could you post a small snippet of code so I can take a look? As to the extending collection, adding that feature is on our todo list as Tony stated. |
@mtnlife999 Thanks for the update.. I will try to reproduce my issues with the current versions of everything and get back to you! |
@mtnlife999 Setting up an example based off your books samples, I encountered something I guess you have as well.. The fetched collection actually contains the data, but has no length.. I see that your commit 259ac41 addresses this issue.. :) I'm updating from the git repo right now and will try it out with my apps here, and then we can probably just close this issue.. Thanks for the help! |
@hedlund: Yes please let me know if the fix works for you. |
I'm wondering if I'm doing something stupid, but I simply can't get any results from invoking fetch() on a collection. Saving models works fine, and I've opened the alloy.sql file in a DB editor and can see that my table contains records. Tracing through the code, and can see that the SQL commands are invoked right in sql.js getting the appropriate results (saved into model.models). But once the call traces back through alloy.js, the result is always an empty collection.
Looking into the backbone.js fetch() function, I can see that the success callback is never called (line 758 in backbone.js):
I'm not sure how the alloy DB implementation and backbone is supposed to be tied together, so I'm not sure where to start fixing things..
What do you guys thing - is something broken here, or am I just doing something wrong?
The text was updated successfully, but these errors were encountered: