hhtokpinar / sqfEntity

SqfEntity ORM for Flutter/Dart lets you build and execute SQL commands on SQLite database easily and quickly with the help of fluent methods similar to .Net Entity Framework. SqfEntity also generates add/edit forms with validations and special controls (DropDown List, DateTime pickers, Checkboxes.. etc) for your table.
379 stars 101 forks source link

Streams for monitoring changes made to the database #159

Open mprync opened 3 years ago

mprync commented 3 years ago

Hi, great job on this framework! I come from Entity Framework and this fits the bill just nicely. I absolutely hate Moor's syntax...

I am interested in adding streams implicitly into this framework. It would mean something like this syntax...

products.select( (product) => ... ).watch().

That returns a stream and will watch for any changes inside the products table, then returns any new record added. This can get complex with creating a stream from a big query.

As an example, Moor has this feature and it's quite a big feature to have for embedded databases.

Imagine having a list of items in an app, and you can to update the list every time the table gets a new item added, which can be from multiple sources. The stream will be updated with the new record and the UI will update via the StreamBuilder widget.

You will not have to worry about updating the UI with a new record as it's done for you with a stream.

This framework as the potential to become more popular than Moor it just needs a few features to get there.

I would also be interested in donating for this feature as it really is an important feature to have.

hhtokpinar commented 3 years ago

Hi @InFaMoUsZero

Thanks for your interest. I come from .Net too. At first, I developed an ORM framework for .Net 10 years ago and adapted it to dart language 2 years ago because I was interested in the flutter and their syntax was similar to each other. But I don’t know how to implement or add an extra future for streaming as you said. I’ve added many features since adapted it and never thought that it would grow this big. So I’m afraid that it will need more effort and others' help as a contributor or donate as you said. Besides you can see how many developers need this package by looking at the number of donators :) but I'm open to suggestions...

hhtokpinar commented 3 years ago

112

Abhijit-Revamp commented 3 years ago

Any update on this? Can this be prioritised?

hhtokpinar commented 3 years ago

I’m sorry, I haven’t done any research yet. Idk if I need to check for new data every second Or SQFLite has that skill and I just need to implement it. What are your thoughts?

Abhijit-Revamp commented 3 years ago

May be this is a good starting point - the article may be outdated. Need to define streams on all CRUD operation.

https://www.freecodecamp.org/news/using-streams-blocs-and-sqlite-in-flutter-2e59e1f7cdce/

mprync commented 2 years ago

Sorry I've been away a while, was there any update on this functionality?

mprync commented 2 years ago

I’m sorry, I haven’t done any research yet. Idk if I need to check for new data every second Or SQFLite has that skill and I just need to implement it. What are your thoughts?

What you'll need to do is, when any CRUD operation happens on the low level, you will check each stream which is usually a table, if the CRUD operation affected that table (updated or inserted a new entry) then update the stream with that.

Essentially it happens only when the db changes, not need to make it complicated by polling the database.