Abstraction Layer for Simpler GRDB Developer Experience #1054
                  
                    
                      cliftonlabrum
                    
                  
                
                  started this conversation in
                Ideas
              
            Replies: 1 comment
-
| Hello @cliftonlabrum, thank you for your feedback. I'm sorry you feel overwhelmed sometimes, and there certainly are improvements to bring. Some things are not about to change, though. The focus on the database schema is there to stay, for instance. Database design is a useful skill, and I'd rather have more people learn about it, and turn the database on their side. This tool is intended to be sharp, as the tool of a craftsman. It is not intended to be "impressive" or painful to use, though. Maybe the abstraction layer you describe can exist at the level of your applications, first. The singleton, for example? | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
I apologize if this is the wrong place for this, but I have a few ideas to pass along. I consider myself to be a reasonably intelligent person, but I'm never the smartest developer in the room. I've used Realm for years based on how easy it was to get started. I have also used Core Data, SQLite.swift, and FMDB in previous projects.
Maybe GRDB is too advanced for me, but every time I look into it, I go through this cycle:
TableRecordextensions, migrations, etc.I would love to see some kind of abstraction layer written for GRDB for those of us that are just trying to use SQLite quickly and easily in a Swift app. Here's how I envision that working (which, you'll see, follows how it works with Realm):
Step 1
Allow me to define a special GRDB
structthat defines my record type(s). Let me focus on the properties and their data types. Don't make me choose protocols--just add all the superpowers by default.Step 2
GRDB uses my
structto infer the rest of what I need in order to be able to query and add records of that type, including inheritance from whatever protocols are needed, table column references, convenience methods for creating and editing objects, etc.Step 3
After setting the SQLite file's name and path, provide an out-of-the-box database singleton. Something like:
With Realm, I just do
let realm = try! Realm()anywhere in my code and I'm immediately interacting with my database. I wish GRDB would do something similar so I don't have to build the singleton, work out the convenience methods for adding/removing/editing objects, setting up database writers/readers, and a bunch of other stuff I've seen in a sample app that is over my head.I'm really not trying to sound negative or that I'm minimizing how much has gone into this impressive project. I'm just suggesting that a simpler developer experience could make it even better for those of us not fully comfortable with the level of complexity.
Maybe GRDB already does everything I'm talking about and I just missed it. If so, I'd love to learn more!
Thanks for hearing me out! 😊
Beta Was this translation helpful? Give feedback.
All reactions