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

YapDB.View public API missing the useful bits #67

Open
aranasaurus opened this issue Oct 16, 2015 · 6 comments
Open

YapDB.View public API missing the useful bits #67

aranasaurus opened this issue Oct 16, 2015 · 6 comments

Comments

@aranasaurus
Copy link
Contributor

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.

  • .object on the enum is not public
  • createDatabaseView() is not public
  • registerInDatabase() is not public
@aranasaurus
Copy link
Contributor Author

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.

@danthorpe
Copy link
Owner

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) }
}

@aranasaurus
Copy link
Contributor Author

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.

@danthorpe
Copy link
Owner

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.

@danthorpe danthorpe modified the milestone: 2.3 Oct 21, 2015
@aranasaurus
Copy link
Contributor Author

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 👍

@danthorpe
Copy link
Owner

Okay, sounds good, we're on the same page.

@danthorpe danthorpe modified the milestone: 2.3 Nov 9, 2015
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

2 participants