New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiple-database support #43
Comments
What scenario requires you to have two sql databases? |
I have a scenario where I need to have one database per user, and I'd also like to have one database with non-user data. So, I need to have two databases open at all times. One for user-data and one for non-user data. And the reason I need one database per user, is I need to encrypt them (SQLCypher) with the user's password. |
This was the first thing I asked Marco when I started using FCModel. We had a similar need but went without the multiple. I could easily see your scenario creeping into our app as well. (Will delete other duplicate comment in the morning) |
I just added a I'm not sure if full-fledged multiple-database support is worth the complexity. It would require a lot more code and a lot of tiny but frequent lookups and checks. If it ends up that a lot of people really need this, it may be worth adding, but I'm not sure it's really needed that badly by most people. Let's discuss use-cases where multiple databases are the only reasonable option to try to get an idea of how common and necessary they really are. @hartdev: Could you just put everything in the encrypted DB? Are multiple users being logged in simultaneously in your app? @johncblandii: Has using the combined database been problematic or particularly awkward for you? |
@marcoarment, no. I was able to get us to move away from that need. There is a definite possibility of it returning though but for now NSUserDefaults is our friend, since data security isn't an issue. Our databases are specific to a user by name though. It definitely adds complexity for multiple DBs. Worst case scenario, use FCModel for the user db and just direct FMDB for the other one; in other words, your app supports multiple DBs but not FCModel. Odd, I know, but feasible now without complicating FCModel. |
Based on this discussion, I think it's best to keep FCModel single-database for now. Feel free to discuss again in the future. |
+1 I have a database using SQLCipher and a General database. It would be perfect to have FCModel supporting multiple-database. |
The way it works right now, FCModel is implemented as a bunch of class methods, relying on private global variables. It's kind of convenient, but not as flexible as I'd like. This has caused me a few issues when I wanted to open more than one database at once (for example).
Wouldn't it be more flexible to separate the library into
FCModel
, the subclass of all database table/classes, and aFCDatabase
orFCManager
, that handles the connection to one database?The text was updated successfully, but these errors were encountered: