simolus3 / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
2.55k stars 365 forks source link

[drift_flutter] driftDatabase more options #3183

Open FMorschel opened 3 weeks ago

FMorschel commented 3 weeks ago

Is your feature request related to a problem? Please describe. I'd like to be able to use the new API but it is missing some options currently.

Describe the solution you'd like In my specific case, I'm missing the logStatements and the ability to select whether or not to run the DB in a separate isolate. There are probably more options that others will miss but in my case, only those would satisfy.

simolus3 commented 3 weeks ago

and the ability to select whether or not to run the DB in a separate isolate

I agree with the logStatements option (although that should potentially be a custom QueryInterceptor for better integration with other logging packages), but why would you want to run the database in the same isolate? drift_flutter is supposed to apply drift with reasonable defaults for Flutter projects, and it seems to me that hosting the database in the same isolate as the UI is not a reasonable default.

FMorschel commented 3 weeks ago

I don't think it should be the default, but to have the option to do it would be nice.

Maybe I'm not familiar enough with isolates and their performances today but wouldn't they take some time to copy the variables to the main isolate every time? That could be something unwanted in some cases for small dbs I think, wouldn't it?

Anyway, if you don't think that's valid I don't think I could make a better point than the above and you can simply ignore that.

Also not sure if there are any other parameters that would be good to have the option but I think since you know the API you can probably think of them and add to this as well.