Labs/Sprints/People: Difference between revisions

 
(3 intermediate revisions by the same user not shown)
Line 56: Line 56:
Currently, the store uses transactions internally to add each person (because data is split up over multiple tables), so there is no public API for dealing with database transactions.  In the future, we may add this functionality.
Currently, the store uses transactions internally to add each person (because data is split up over multiple tables), so there is no public API for dealing with database transactions.  In the future, we may add this functionality.


The object to pass in to <tt>add</tt> and <tt>update</tt> and returned by <tt>find</tt> look like the sample below. Currently, by default, we're storing a single [http://portablecontacts.net/draft-spec.html#schema Portable Contacts object] within the wrapper object, with the addition of a <tt>moz_schema</tt> field.
The object to pass in to <tt>add</tt> and <tt>update</tt> and returned by <tt>find</tt> look like the sample below. Currently, by default, we're storing a single [http://portablecontacts.net/draft-spec.html#schema Portable Contacts object] within the wrapper object.  Note that the schema for the 'default' document is contained in the <tt>default</tt> property of <tt>documentSchemas</tt>.  Be sure to verify the schema string, as the People store will not enforce adherence to Portable Contacts or any other schema.


<pre>
<pre>
Line 63: Line 63:
   // guid identifies this person, schema describes the wrapper object
   // guid identifies this person, schema describes the wrapper object
   guid: "af24d-fe488-ab748-b947f",
   guid: "af24d-fe488-ab748-b947f",
   schema: "http://mozilla.com/schemas/people/1",
   schema: "http://labs.mozilla.com/schemas/people/1",


   // we pull out some fields for convenience.
   // we pull out some fields for convenience.
   // we only index fields we pull out.
   // we only index fields we pull out.
   firstname: "foo"
   displayName: "the foobinator",
   lastname: "bar"
  givenName: "foo",
   familyName: "bar",


   documents: [
   documents: {
     {
     default: {
       moz_schema: "http://portablecontacts.net/draft-spec.html",
       displayName: "the foobinator",
       firstname: "foo",
       name{
      lastname: "bar",
        givenName: "foo",
        familyName: "bar"
      },
       emails: [
       emails: [
         {value: "foo@gmail.com"},
         {value: "foo@gmail.com", type: "home"},
         {value: "foo@yahoo.com"},
         {value: "foo@yahoo.com", type: "work"},
         {value: "bar@yahoo.com"}
         {value: "bar@yahoo.com", type: "other"}
       ]
       ]
     }
     }
   ]
   },
  documentSchemas: {
    default: "http://portablecontacts.net/draft-spec.html"
  }
}
}
</pre>
</pre>
946

edits