Coder Social home page Coder Social logo

Comments (4)

billymedia avatar billymedia commented on June 14, 2024

What is the most efficient way of storing multiple items? I am using parse.com and want to store data locally which could run into thousands? is localforage ideal for this? i plan to use angular.foreach.

from angular-localforage.

ocombe avatar ocombe commented on June 14, 2024

If you don't need to get each item separately you can set an array and get it all in once.
If each item should be independent, you can loop, store each promise in an array and do a $q.all() at the end (if you need to use the promise, otherwise don't bother).
It should work well in modern browsers, but be careful if you have to use local storage because it is synchronous (the lib uses the best storage available, but old browsers like IE8/9 don't support indexedDB / WebSQL, so it will switch to local storage...)
I'm not sure how it would behave (the lib is asynchronous in itself, so it shouldn't freez the browser, but it might make it less responsive). You should try it (you can force the driver to use local storage if you want to test the worse possible scenario).

If I have the time, I'll try to implement this new function this week end to set/get multiple items all in once, it would make your life easier.

from angular-localforage.

billymedia avatar billymedia commented on June 14, 2024

Wow, thanks for the response.
I forgot to mention that the app is a phonegap one targeting android and ios only. I am trying to implement a localstorage facility thus reducing calls to parse.com.
I will need to search through records and filter them which i am still undecided on, i.e. store locally and query or query parse.com directly.

I have it storing multiple like so but my test dataset is only 10 records so i need to create a random sample of say, 10k (worst case) and see how it performs:

var events = [];
            angular.forEach(results.models, function(event) {
                this.push({
                    'name'  : event.getName(),
                    'time'  : event.getTime(), 
                    'date'  : event.getDate()
                });
            }, events);
            $localForage.setItem('PublicEvents',events);

from angular-localforage.

ocombe avatar ocombe commented on June 14, 2024

If it's for iOS and Android then you shouldn't have a problem, but support either indexedDB or WebSQL which are asynchronous and way better (in terms of performances and storage capacity) than local storage.
If you intend to store all your events in one time (with one key), then it will be super fast (only one write / read).

from angular-localforage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.