Thunder
Joined 16 October 2006
No edit summary |
(→People) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
== People == | == People == | ||
sample people data: | Here's some sample people data. To use it, copy the whole thing (including the JS) and paste it into the error console: | ||
<pre> | <pre> | ||
Components.utils.import("resource://people/modules/people.js"); | |||
People.add( | |||
[{ | |||
guid: "guid0", | |||
schema: "http://labs.mozilla.com/schemas/people/1", | |||
displayName: "The Dolskenator", | |||
givenName: "Justin", | |||
familyName: "Dolske", | |||
emails: [ | |||
{value: "dolske@mozilla.com"} | |||
], | |||
documents: { | |||
default: { | |||
moz_schema: "http://portablecontacts.net/draft-spec.html", | |||
displayName: "The Dolskenator", | |||
name: { | |||
givenName: "Justin", | |||
familyName: "Dolske" | |||
}, | |||
emails: [ | |||
{value: "dolske@mozilla.com"} | |||
] | |||
} | |||
} | |||
}, | |||
{ | { | ||
guid: "guid1", | guid: "guid1", | ||
Line 19: | Line 47: | ||
givenName: "Dan", | givenName: "Dan", | ||
familyName: "Mills", | familyName: "Mills", | ||
emails: [ | |||
{value: "thunder@mozilla.com"} | |||
], | |||
documents: { | documents: { | ||
Line 41: | Line 73: | ||
givenName: "Myk", | givenName: "Myk", | ||
familyName: "Melez", | familyName: "Melez", | ||
emails: [ | |||
{value: "myk@mozilla.com"} | |||
], | |||
documents: { | documents: { | ||
Line 63: | Line 99: | ||
givenName: "Anant", | givenName: "Anant", | ||
familyName: "Narayanan", | familyName: "Narayanan", | ||
emails: [ | |||
{value: "anant@mozilla.com"} | |||
], | |||
documents: { | documents: { | ||
Line 83: | Line 123: | ||
displayName: "Fred", | displayName: "Fred", | ||
emails: [ | |||
{value: "fred@example.com"}, | |||
{value: "fred2@example.com"} | |||
], | |||
documents: { | documents: { | ||
Line 89: | Line 134: | ||
displayName: "Fred", | displayName: "Fred", | ||
emails: [ | emails: [ | ||
{value: "fred@example.com"} | {value: "fred@example.com"}, | ||
{value: "fred2@example.com"} | {value: "fred2@example.com"} | ||
] | ] | ||
Line 107: | Line 152: | ||
} | } | ||
} | } | ||
} | }]); | ||
</pre> | |||
To then verify the contacts were added correctly, run these in the error console: | |||
Find all contacts: | |||
<pre> | |||
Components.utils.import("resource://people/modules/people.js"); | |||
People.find({}); | |||
</pre> | |||
Find all contacts and output raw data as JSON: | |||
<pre> | |||
Components.utils.import("resource://people/modules/people.js"); | |||
JSON.stringify(People.find({})); | |||
</pre> | |||
Find all contacts with display name "Barney" | |||
<pre> | |||
Components.utils.import("resource://people/modules/people.js"); | |||
JSON.stringify(People.find({displayName: "Barney"})); | |||
</pre> | |||
Find all contacts with "thunder@mozilla.com" emails: | |||
<pre> | |||
Components.utils.import("resource://people/modules/people.js"); | |||
JSON.stringify(People.find({emails: ["thunder@mozilla.com"]})); | |||
</pre> | </pre> |
Latest revision as of 00:16, 7 August 2009
Firefox 3
Weave
People
Here's some sample people data. To use it, copy the whole thing (including the JS) and paste it into the error console:
Components.utils.import("resource://people/modules/people.js"); People.add( [{ guid: "guid0", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "The Dolskenator", givenName: "Justin", familyName: "Dolske", emails: [ {value: "dolske@mozilla.com"} ], documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "The Dolskenator", name: { givenName: "Justin", familyName: "Dolske" }, emails: [ {value: "dolske@mozilla.com"} ] } } }, { guid: "guid1", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Dan Mills", givenName: "Dan", familyName: "Mills", emails: [ {value: "thunder@mozilla.com"} ], documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Dan Mills", name: { givenName: "Dan", familyName: "Mills" }, emails: [ {value: "thunder@mozilla.com"} ] } } }, { guid: "guid2", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Myk Melez", givenName: "Myk", familyName: "Melez", emails: [ {value: "myk@mozilla.com"} ], documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Myk Melez", name: { givenName: "Myk", familyName: "Melez" }, emails: [ {value: "myk@mozilla.com"} ] } } }, { guid: "guid3", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Anant", givenName: "Anant", familyName: "Narayanan", emails: [ {value: "anant@mozilla.com"} ], documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Anant", name: { givenName: "Anant", familyName: "Narayanan" }, emails: [ {value: "anant@mozilla.com"} ] } } }, { guid: "guid4", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Fred", emails: [ {value: "fred@example.com"}, {value: "fred2@example.com"} ], documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Fred", emails: [ {value: "fred@example.com"}, {value: "fred2@example.com"} ] } } }, { guid: "guid5", schema: "http://labs.mozilla.com/schemas/people/1", displayName: "Barney", documents: { default: { moz_schema: "http://portablecontacts.net/draft-spec.html", displayName: "Barney" } } }]);
To then verify the contacts were added correctly, run these in the error console:
Find all contacts:
Components.utils.import("resource://people/modules/people.js"); People.find({});
Find all contacts and output raw data as JSON:
Components.utils.import("resource://people/modules/people.js"); JSON.stringify(People.find({}));
Find all contacts with display name "Barney"
Components.utils.import("resource://people/modules/people.js"); JSON.stringify(People.find({displayName: "Barney"}));
Find all contacts with "thunder@mozilla.com" emails:
Components.utils.import("resource://people/modules/people.js"); JSON.stringify(People.find({emails: ["thunder@mozilla.com"]}));