Code Monkey home page Code Monkey logo

Comments (5)

alextekartik avatar alextekartik commented on September 28, 2024 2

As sembast loads everything in memory, I would not advise using it to store 500 000 documents unless you have tons of memory. And no there is no index. If you do actually try it, I would be interested to know if it works and the performance! Sembast should be ok for small to medium database (whatever that means, I have tried up to 100 000 records of about 1kb each). For big databases, I'd rather user sqflite (without any ORM to optimize as much as possible)

from sembast.dart.

carotkut94 avatar carotkut94 commented on September 28, 2024

what if I am storing 50,000 items and need to get the data in pages based on some category id, would it be fine with it? and if so then how do I implement the paging in dao class, and how do I replace item if two items have same id?

from sembast.dart.

alextekartik avatar alextekartik commented on September 28, 2024

There is no dao support in sembast itself and I don't know how well it can play with existing solutions. I'm personnally not a fan of code generation that I don't have control on. Not sure about the kind of paging support you need. There is like in sqflite a notion of offset and limit, but it is not very efficient (if there is sorting, it still needs to sort everything first). Like on firestore, there is query mechanism you can listen to (store.query.onSnapshots) that should take care of properly updating the result for display without any paging needs.

Unfortunately, it is hard to give strong advices. I understand you don't want to get stuck with some unknown limitations but cannot at this point tell you whether it will match all your needs. As I said earlier, I use sqflite for big database. Once you try it, if you have some needs and suggestions I'll be all ears to suggestions and improvements....

from sembast.dart.

carotkut94 avatar carotkut94 commented on September 28, 2024

ok, understood, but the real and basic question that i have to ask is, lets say i have a json
{ "id":1, "name":"Sidhant" }

and insert this into the "users" store now another user comes up with same id, but different name, i should ideally replace the old record with the same id, but it does no do that, it inserts it as a new record.

and I am trying to update the record but it always fails

Future<int> updateQuantity(CartModel cartModel) async {
    int updatedRows =
        await _categoryStore.update(await _db, {"quantity": cartModel.quantity},
            finder: Finder(
                filter: Filter.and([
              Filter.equals("product_id", cartModel.productId),
              Filter.equals("packageTypeId", cartModel.packageTypeId)
            ])));
    return updatedRows;
  }

and by paging i meant, lets say i have 100 products , and i dont want to load all of them at once in the listview, rather i will load 10 record in per page i.e i will be having the 10 pages having 10 records each and as soon as i scroll to end, i will load another page

from sembast.dart.

alextekartik avatar alextekartik commented on September 28, 2024

Many questions at once, not all related.

  1. you should make the id field the key of the record => userStore.record(map['id']).put(db, map) or use a transaction to find the existing record first if any before adding or upting it (userStore.findFirst(txn, finder: Finder(filter: Filter.equals('id', map['id'])))

  2. Hard to says without seeing more code, the existing content, whether column names are corrent - some are camelCase some have under_score - , what you mean by not working...if you have more code (and event better a unit test) that explains the issue you are seeing can you fill a new issue as this is not related to the current one.

  3. ok then offset/limit is your friend

from sembast.dart.

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.