Firefox/Projects/PlacesQueryAPIRedesign: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 7: Line 7:
*An elegant and easy to use API. Fx devs, Jetpack and extension developers will all benefit.  
*An elegant and easy to use API. Fx devs, Jetpack and extension developers will all benefit.  
*allows us to prototype the new ui for Fx.next  
*allows us to prototype the new ui for Fx.next  
*<strike>'Pluggable' results handling</strike> Easy wrappable querying object and results<br>
*<strike>'Pluggable' results handling</strike> Easy wrappable querying object and results<br>  
*Focus on JS usage  
*Focus on JS usage  
*<strike>Paging Support - Sounds like a great use of Generators!</strike> dropped, there is no perf gain, can be a follow-up<br>
*<strike>Paging Support - Sounds like a great use of Generators!</strike> dropped, there is no perf gain, can be a follow-up<br>  
*Fetch individual record by Id or other property
*Fetch individual record by Id or other property


<strike>(After talking to the Labs guys about Weave, we should try to provide a plugin-interface whereby you can allow a developer to keep track of and index random JSON objects.</strike>
<strike>(After talking to the Labs guys about Weave, we should try to provide a plugin-interface whereby you can allow a developer to keep track of and index random JSON objects.</strike>  


<strike>Dan Mills has example code that was created for the people store. Link coming soon.)</strike>
<strike>Dan Mills has example code that was created for the people store. Link coming soon.)</strike>  


== Non Goals  ==
== Non Goals  ==
Line 20: Line 20:
*Tailoring the API to tree views  
*Tailoring the API to tree views  
*Creating the perfect API (lets iterate)  
*Creating the perfect API (lets iterate)  
*Create an abstract datastore<br>
*Create an abstract datastore<br>  
*<strike>Intended as a snap-in replacement of the current API</strike> Future follow-up through a live-updating wrapper<br>
*<strike>Intended as a snap-in replacement of the current API</strike> Future follow-up through a live-updating wrapper<br>  
*Wrap current sync and XPCOM API
*Wrap current sync and XPCOM API


== Status  ==
== Status  ==


*Old prototype landed in Jetpack 0.8, currently being revised<br>
*Old prototype landed in Jetpack 0.8, currently being revised<br>  
*Team  
*Team  
**'''API''': ddahl, mak  
**'''API''': ddahl, mak  
Line 54: Line 54:


*Comprehensive xpcshell tests  
*Comprehensive xpcshell tests  
*<strike>Example/Documentation style Browser Chrome tests</strike> Not for now, when treeviews will use this.<br>
*<strike>Example/Documentation style Browser Chrome tests</strike> Not for now, when treeviews will use this.<br>  
*TDD
*TDD


Line 81: Line 81:
Explicit Attribute Provider: [http://mxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/explattr.js]  
Explicit Attribute Provider: [http://mxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/explattr.js]  


FacetView: [http://mxr.mozilla.org/comm-central/source/mail/base/content/glodaFacetView.js]
FacetView: [http://mxr.mozilla.org/comm-central/source/mail/base/content/glodaFacetView.js]  
 
== Current Sketches  ==
<pre class="brush:js;toolbar:false;">function callback(results) {
  // results is a simple array of ResultItem, it's pretty easy to wrap it
  // if more complex management is needed.
  if (results.length == 0)
    dump("En empty results array indicates last results push\n");
  else
    dump("Collected " + results.length + " results this turn\n");
}
 
// Results are pushed to the callback as soon as they are available.
new PlacesQuery([object]QueryConf, [function]callback, [scope]thisObject);
 
// It's possible to pass multiple QueryConf objects, results will be merged
// based on the .merge attribute of each config.
// First query results are always unioned.
// In case of multiple queries, sort, group and limit of the first query will
// be used for the global result.
new PlacesQuery([QueryConf1, QueryConf2], callback, thisObject);
 
// It's possible to create the query, but run it later.
let query = new PlacesQuery(QueryConf);
query.execute(callback, thisObject);
 
//The query can be so configured:
QueryConf = {
 
  phrase: string.
          Show only pages containing this string in either title, uri or
          tags.  Case insensitive.  Can use ^ and $ to match beginning or
          end.
 
  host: string.
        Show only pages containing this string in the host.  Case
        insensitive.  Can use ^ and $ to match beginning or end.
 
  uri: string.
      Show only pages containing this string in the uri.  Case
      insensitive.  Can use ^ and $ to match beginning or end.
 
  annotated: array of strings.
            Show only pages with these annotations (Either page or item).
 
  bookmarked: object {
    tags: array of strings.
          Show only pages tagged with these tags.
    folders: array of numbers.
            Show contents of these folders. (non-recursive)
    items: array of numbers.
          Show only these items.
    when: array of 2 Date objects.
          Show only bookmarks created between these times.
          Can use null beginning or end time to match till epoch
          or now.
    modified: array of 2 Date objects.
              Show only bookmarks modified between these times.
              Can use null beginning or end time to match till
              epoch or now.
    excludeNonContainers: boolean.
                          Removes any non-container from results.
                          Default is false.
    excludeReadOnlyContainers: boolean.
                              Removes read only containers from
                              results.  Default is false.
  }
 
  visited: object {
        howMany: array of numbers.
                  Show only pages with these so many visits.
                  Can use null minimum or maximum to match anything.
        transitions: array fo transition types.
                      Show only pages with at least one visit with these
                      transitions.
        when: array of 2 Date objects.
              Show only pages with visits between these times.
              Can use null beginning or end time to match till epoch
              or now.
        excludeRedirectsSources: boolean.
                                  Removes redirects sources from results.
                                  Default is false.
        excludeRedirectsTargets: boolean.
                                  Removes redirects targets from results.
                                  Default is false.
        includeHiddenPages: boolean.
                            Returns also pages marked as hidden.
                            Default is false.
        includeVisits: boolean.
                        Returns all visits.
                        Default is false, that means visits are grouped
                        by uri, and no duplicates are returned.
  }
 
  sort: object {
    by: string.
        Either "none", "title", "time", "uri", "accessCount" or
        "lastModified", "frecency".  Defaults to "none".
    dir: string.
        Either "asc" or "desc".  Defaults to "asc".
  }
 
  group: string.
        Either "tags", "folders", "day", "month", "year" or "domain".
        Defaults to "none".
 
  limit: number.
        Maximum umber of results to return.  Defaults to all results.
 
  merge: string.
        How to merge this query's results with others in the same request.
        Either "union", "intersect" or "except".
}
 
</pre>
Confirmed users
595

edits

Navigation menu