Comments (5)
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.
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.
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.
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.
Many questions at once, not all related.
-
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']))
) -
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.
-
ok then offset/limit is your friend
from sembast.dart.
Related Issues (20)
- Serialising object works fine, deserialising fails HOT 2
- How do I chain/make compound filters? HOT 3
- Issue using Sembast in Background Notification - Android HOT 6
- Deleted row in the .db file HOT 7
- Using sync to fetch data HOT 3
- Any database viewer is available to view the sembast db file HOT 1
- Export JsonEncodableCodec type HOT 4
- Copy db file on flutter web for upload / backup HOT 2
- Need a way to reload the database / detect that it was changed by an external process. HOT 4
- Error in mobile web browser HOT 2
- Sembast web limitation HOT 2
- how to rename a store? HOT 2
- Pagination not working HOT 2
- Store record with custom key HOT 1
- Ambiguity around null record value HOT 3
- null check on null value HOT 4
- Problem: record is updated even merged is false HOT 5
- Reload data from database HOT 3
- OutOfMemoryError: Out of Memory HOT 10
- Can not filter by timestamp. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sembast.dart.