Skip to content
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

Closed
hartbit opened this issue Mar 31, 2014 · 7 comments
Closed

Add multiple-database support #43

hartbit opened this issue Mar 31, 2014 · 7 comments

Comments

@hartbit
Copy link

hartbit commented Mar 31, 2014

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 a FCDatabase or FCManager, that handles the connection to one database?

@LukeDurrant
Copy link
Contributor

What scenario requires you to have two sql databases?
Sorry not helpful! Just curious

@hartbit
Copy link
Author

hartbit commented Mar 31, 2014

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.

@johncblandii
Copy link

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)

@marcoarment marcoarment changed the title Class methods Add multiple-database support Mar 31, 2014
@marcoarment
Copy link
Owner

I just added a closeDatabase call, which isn't really what you're asking for, but might get you partly there.

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?

@johncblandii
Copy link

@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.

@marcoarment
Copy link
Owner

Based on this discussion, I think it's best to keep FCModel single-database for now. Feel free to discuss again in the future.

@paventuri
Copy link

+1

I have a database using SQLCipher and a General database.

It would be perfect to have FCModel supporting multiple-database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants