-
Notifications
You must be signed in to change notification settings - Fork 72
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.load() doesn't seem to work as described in documentation #49
Comments
Hey ya, I'm a bit confused about your question, specifically:
Any stored data is loaded into the collection and the call to load() then tells the callback if an error occurred (which almost always will be false - which is expected behaviour).
Returning err = false doesn't mean the data isn't loaded. |
Okay, so it appears that collection.load() just check to see if the collection exists and if it does, it loads it. However, how would you recommend handling my scenario? I want to load the local collection not only if it exist but it contains data (particularly the case when a user changes the route (SPA)). However, if the collection is empty, it needs to be loaded. |
The .load() method will only return an error if it actually fails, not if persistent storage data exists or not. I can add an operation summary as data in the second returned parameter in the callback if you like that will describe if data was found and if so, how many records were found. I think that would solve your problem. It would be something like this:
If that would solve your problem let me know! |
Please clone the dev branch and let me know if that solves your issue as usage is described above. |
Thanks for working on this. I grabbed dist/fdb-core+persist.js from your dev branch and attempted to use it. It doesn't appear to have the new code. Which one should I use? |
Hmm, it should do! But try using fdb-all.js first. That definitely has it as it is an "all modules enabled" build. core+persist should be ok though... |
Oops, looks like my example above was incorrect, the operation data comes back in the third argument of the callback, not the second. I've updated the example above. |
Just to say I came across this issue as I wanted to load the data at app startup from persistent storage, falling to network request if data not found. The callback params are perfect to check this out. As this could be very useful (IMHO), I suggest you to include in the documentation for the I found cheers |
I believe the API has been updated since this issue was raised. The callback now contains: callback(err, tableStats, metaStats); The err is obvious, either falsy for no error or something non-falsy for an error. The other two are: tableStats - The details about the data loaded for the collection. I will update the load method docs to reflect this. :) |
OK, I've updated the docs on the edge branch as per the commit shown above. |
I'm attempting to use ForunnerDB in a single page app. I'm using one collection. It is loaded the first time the app runs. After that, on relevant views I'm expecting to check to see if it's loaded. If it isn't, I need to reload it.
Whenever I use load, it always returns err as false, which means it never loads the data initially. Here's some code. Please let me know what I'm doing wrong.
The text was updated successfully, but these errors were encountered: