mozilla
Your Search Results

    ContactManager.getAll()

    This article is in need of a technical review.

    Non-standard
    This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

    This API is available on Firefox OS for privileged or certified applications only.

    Summary

    The getAll method is used to access a sorted list of contact from the device's contact database. This method is best suited to access a large data set, where find() is better suited for a small data set.

    Syntax

    var instanceOfDomCursor = window.navigator.mozContacts.getAll(options);
    

    Parameters

    options
    The getAll method expects some options to sort and filter the contacts. The possible options are the following:
    Sort options
    • sortBy: A string representing the field by which the results of the search are sorted. Currently only givenName and familyName are supported.
    • sortOrder: A string indicating the result's sort order. Possible values are descending or ascending.
    Filter options
    • filterBy: An array of strings representing all the fields to filter by.
    • filterValue: The value to match against.
    • filterOp: The filter comparison operator to use. Possible values are equals, startsWith, and match, the latter being specific to telephone numbers.
    • filterLimit: The number of contacts to retrieve.

    Return value

    A DOMCursor object to handle the success or error of the operation. In case of success, the request's result is a mozContact object. To move to the next result, call the cursor's continue() method.

    Example

    var filter = {
      sortBy: familyName,
      sortOrder: ascending,
      filterBy: ['familyName'],
      filterValue: 'a',
      filterOp: startsWith
    }
    
    var request = window.navigator.mozContacts.getAll(filter);
    var count = 0;
    
    request.onsuccess = function () {
      if(this.result) {
        count++;
    
        // Display the name of the contact
        console.log(this.result.givenName + ' ' + this.result.familyName);
    
        // Move to the next contact which will call the request.onsuccess with a new result
        this.continue();
    
      } else {
        console.log(count + 'contacts found.');
      }
    }
    
    request.onerror = function () {
      console.log('Something goes wrong!');
    }
    

    Specifications

    Specification Status Comment
    Contacts Manager API
    The definition of 'Contacts Manager API' in that specification.
    Working Draft First Working Draft (unstable)
    vCard Format Specification RFC RFC6350

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    basic support Not supported Not supported Not supported Not supported Not supported
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    basic support Not supported Not supported 18.0 Not supported Not supported Not supported

    Gecko Note

    As the specification is unstable, the Gecko implementation is completely non-standard.

    See also

    Document Tags and Contributors

    Contributors to this page: kscarfone, Mte90, kollishivagangadhar, fscholz, Jeremie
    Last updated by: fscholz,