ContactManager.find()

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 find method is used to retrieve a limited list of contacts from the device's contact database. This method is best suited to access a small data set, where getAll() is better suited for a large data set.

Syntax

var instanceOfDomRequest = window.navigator.mozContacts.find(options);

Parameters

options
The find method expects some options to filter the contacts in order to reduce the size of the resulting list. The possible options are the following:
  • filterBy: An array of strings representing all the fields to filter by.
  • filterValue: The value to match against.  Because of Bug 1093105 if you are using the equals filterOp you will need to manually call toLowerCase() on any string values you pass in because the Contacts API normalizes all strings in its index but fails to normalize the passed-in filterValue in the case of equals.  startsWith automatically normalizes correctly.
  • 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 DOMRequest object to handle the success or error of the operation. In case of success, the request's result is an array of mozContact objects.

Example

var filter = {
  filterBy: ['name', 'nickname', 'firstName'],
  filterValue: 'zorro',
  filterOp: 'equals',
  filterLimit: 100
};

var request = window.navigator.mozContacts.find(filter);

request.onsuccess = function () {
  console.log(this.result.length + ' contacts found.');
}

request.onerror = function () {
  console.log('Something goes wrong!');
}

Specifications

Specification Status Comment
Contacts Manager API
The definition of 'ContactManager.find()' in that specification.
Working Draft  
vCard Format Specification IETF RFC RFC 6350

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

See also

Document Tags and Contributors

Contributors to this page: Sebastianz, fscholz, AndrewSutherland, jsx, Nth10sd, kscarfone, Jeremie
Last updated by: Sebastianz,