YapDatabaseExtensions
YapDatabaseExtensions copied to clipboard
YapDB.View public API missing the useful bits
I may just be missing something and this is supposed to be used from elsewhere or something, but none of the pieces of the YapDB.View api that would let me register it with YapDatabase are marked public, they're all internal.
.objecton the enum is not publiccreateDatabaseView()is not publicregisterInDatabase()is not public
Going further down the rabbit hole I'm finding YapDatabaseViews don't get any of the love from your work on the Transaction or Connection since YapDatabaseExtensionTransaction and YapDatabaseConnection require slightly different info for an index (Group and Index within the group). So I guess we'd need separate extensions written for these classes.
Hi @aranasaurus - sorry just getting back to this.
I can see that YapDB.View etc doesn't have public APIs, but if you put the view into a fetch, then you can register it in the database. i.e.
let fetch: YapDB.Fetch = .View(myView)
let database = YapDB.databaseNamed("MyApp.sqlite") { db in
// Ensure that nothing inside this block attempts to access `database`
// as it will cause a deadlock.
db.registerExtension(YapDatabaseRelationship(), withName: "relationships")
// Register default extensions
let views: [YapDB.Fetch] = [
Reminder.fetch,
Person.view,
Person.search
]
views.forEach { $0.registerInDatabase(db) }
}
Thanks @danthorpe. I wrote an extension on YapDatabaseExtensionTransaction that mirrored your generic read functions, as a quick and dirty fix on Friday and moved on for now. Hopefully I'll get back to it today.
Okay, thanks @aranasaurus - although my comment was more about the availability of the registerInDatabase API.
I'm going to circle back to address the YapDB wrappers for version 2.3, and I'd like to also add APIs on YapDatabaseExtensionsTransaction etc.
I knew you were referring to the registerInDatabase API... I was just saying the read methods on YapDatabaseExtensionTransaction was the quicker way to get me what I needed at the time. And I'll also put forth that doing that made using an extension very straight forward and felt pretty natural with the rest of the Extensions. The Fetch bit seems nice, but feels like a whole separate thing... maybe just because there's not docs for it and I haven't had time to fully grok it yet.
Anyway, long story short, I like the idea of adding the APIs to YapDatabaseExtensionTransaction :+1:
Okay, sounds good, we're on the same page.