agrosner / DBFlow

A blazing fast, powerful, and very simple ORM android database library that writes database code for you.
MIT License
4.87k stars 598 forks source link

What is it DatabaseWrapper? #1661

Closed VeiNPrk closed 3 years ago

VeiNPrk commented 5 years ago

ISSUE_TEMPLATE

DBFlow Version: 5.0.0-alpha1

Bug or Feature Request: save(DatabaseWrapper) in BaseModel cannot be applied Description: Why in the latest version I can not just save the object extended from BaseModel? In the documentation about this does not say anything.

sangxb commented 5 years ago

Did you solve it?

antdeveloper commented 5 years ago

the same problem :/

LeeYKKK commented 5 years ago

Did you solve it?impendency

nikunjparadva commented 5 years ago

@agrosner Please Help us in this Question. What I passed in Save() method?

aiguanglin commented 5 years ago

the same problem too!

Nhitro commented 4 years ago

Hi everyone !

You have to pass your database which now delegates to the DatabaseWrapper

myModel.save(FlowManager.getDatabase(MyDatabase.class));

agrosner commented 3 years ago

Its the database wrapper that provides abstracted functionality that a normal SQLiteDatabase object would provide. So we can swap implementation for other kinds like SQLCipher. You need to be explicit in passing the db in methods from now on as the previous implementation had a few drawbacks:

  1. Every method in the library was then expected to supply a counterpart that took 1 or no database, increasing method count.
  2. By running migrations with wrapper queries you would easily run into stackoverflow issues by leaving out the DatabaseWrapper parameter.
  3. Encourages not using transactions by calling .save() synchronously
  4. Requires implict db lookup by model on every call, which impacts performance.
agrosner commented 3 years ago

new usage docs for 5.0.0-alpha2 https://dbflow.gitbook.io/dbflow/v/develop/usage2/usage/databases hopefully are more clear