Need advice about which tool to choose?Ask the StackShare community!
IndexedDB vs LokiJS: What are the differences?
Data Storage Mechanism: IndexedDB is a native database that stores data in browsers as key-value pairs, providing a robust storage solution for web applications. On the other hand, LokiJS is an in-memory database that can persist data on disk using serialization and deserialization techniques.
Query Capabilities: IndexedDB employs a query language similar to SQL for retrieving data, allowing developers to perform complex queries efficiently. In contrast, LokiJS utilizes a collection-based approach for data manipulation, making it more suitable for simple queries and operations.
Synchronization Support: IndexedDB offers better synchronization support and scalability for applications with large datasets, making it a preferred choice for enterprise-level applications. Meanwhile, LokiJS lacks built-in synchronization features, making it more suitable for smaller-scale applications or prototypes.
Performance Optimization: IndexedDB provides indexes for optimizing query performance, allowing developers to fetch data quickly based on specified criteria. In comparison, LokiJS focuses on in-memory operations, which may lead to faster read and write operations for smaller datasets.
Data Relationships Handling: IndexedDB supports the creation of complex data relationships through object stores and indexes, enabling developers to model intricate data structures efficiently. Conversely, LokiJS simplifies data relationships by using collections and documents, which may be more intuitive for straightforward data models.
In Summary, IndexedDB excels in large-scale data storage and query capabilities, while LokiJS prioritizes performance for small to medium-sized datasets with simpler data relationships.
I'm currently developing an app that ranks trending stuff ( such as games, memes or movies, etc. ) or events in a particular country or region. Here are the specs: My app does not require registration and requires cookies and localStorage to track users. Users can add new entries to each trending category provided that their country of origin is recorded in cookies. If each category contains more than 100 items then the oldest items get deleted. The question is: what kind of database should I use for managing this app? Thanks in advance
I think your best and cheapest choice is going to be MongoDB, Although Postgres is probably going to be the more scaleable approach, you likely have a good idea of how you want to present your data, and the app seems small enough that you shouldn't need to worry about scaling issues. It also sounds like your app can grow in a linear capacity based on the number of users, and the amount of data, which is the perfect use-case for noSQL databases (linear, predictable scaling).
Correct me if I have any of these assumptions wrong. 1. You're looking to have a relatively high-read with a lower write volume 2. Your app is essentially a list of objects that can belong to a category 3. users can create objects in this list.
I think Mongo is going to be what you're looking for on the following basis: 1. you absolutely need a database that is shared by all users of your app, therefor IndexedDB is out of the question. 2. You have semi-structured data 3. you probably want the cheapest solution.
I think Postgres is wrong for the following reasons: 1. your app is pretty simple in concept, SQL databases will add unnecessary complexity to your system, either through ORMs or SQL queries. (use an ORM if you go with SQL) 2. Hosting SQL databases for production is not cheap! the cheapest solution I know of for Postgres is ElephantSQL. It provides 20MB for free with 5 concurrent connections, you should be okay to manage these limitations if you decide to go Postgres in the end. Whereas mongoDB Atlas has some great free-tier options.
Although your data might be easier to model in Postgres, you can certainly model your data as a single list of items that have a category attached.
I don't want to officially recommend another tool, but you should really checkout prisma, firebase, amplify, or Azure App Services for this app! Just go completely backend-less [Firebase] https://firebase.google.com/ [Amplify] https://aws.amazon.com/amplify/ [Prisma] https://www.prisma.io/ [Azure App Services] https://azure.microsoft.com/en-us/services/app-service/?v=18.51
Pros of IndexedDB
Pros of LokiJS
- Can query the objects directly3