ContactManager.find()

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 No support No support No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
basic support No support No support 18.0 No support No support No support

See also

Document Tags and Contributors

 Last updated by: chrisdavidmills,