User:Thunder: Difference between revisions

Jump to navigation Jump to search
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(
Components.utils.import("resource://people/modules/people.js");
{
People.add(
[{
   guid: "guid1",
   guid: "guid1",
   schema: "http://labs.mozilla.com/schemas/people/1",
   schema: "http://labs.mozilla.com/schemas/people/1",
Line 90: Line 91:
       displayName: "Fred",
       displayName: "Fred",
       emails: [
       emails: [
         {value: "fred@example.com"}
         {value: "fred@example.com"},
         {value: "fred2@example.com"}
         {value: "fred2@example.com"}
       ]
       ]
Line 108: Line 109:
     }
     }
   }
   }
})
}]);
</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>
</pre>
946

edits

Navigation menu