awulder / angular-prismicio

AngularJS service for prismic.io
MIT License
32 stars 15 forks source link

Using orderings, pageSize, page, etc. in calls #10

Closed rudyrigot closed 10 years ago

rudyrigot commented 10 years ago

I'm looking into your library today, and I'm noticing that you are abstracting a lot how the kit performs queries. It's fine by itself, but it suppresses a key upside of the official kit: the ability to chain calls to specify your query. For instance:

api.forms('products').query('[[:d = at(document.tag, "featured")]]').orderings('[product.price]').pageSize(10).page(2).ref(ref).submit()

I wonder how best to expose this with the current approach. Maybe simply with a Prismic.api so that we can do stuff such as Prismic.api.forms('products').query('[[:d = at(document.tag, "featured")]]').orderings('[product.price]').pageSize(10).page(2).submit(). This might require to extend the original SearchForm object so that submit() returns a promise, but that could work!

Notice that I haven't used ref. I like the way you've abstracted the call to ref in a clean way, still making it possible to pass another ref in the page's URL.

I can totally make that happen, I just thought I'd reach out first to talk about how to do this best.

rudyrigot commented 10 years ago

Actually, another good reason to expose the Api object: it's not possible to build a select box allowing the authenticated visitor to choose which content release they wish to preview, since the list of accessible content releases is in the Api object.

rudyrigot commented 10 years ago

This would all be possible with PR #13, so this issue is not needed anymore.