B2G/gaia/apps/communications/dialer/js/call_log_db.js
/**
   * Upgrade schema to version 2. Create an object store to host groups of
   * calls and populate this store with the already existing recent calls
   * data.
   *
   * param db
   *        Database instance.
   * param transaction
   *        IDB transaction instance.
   */
Upgrade schema to version 2. Create an object store to host groups of
calls and populate this store with the already existing recent calls
data.

param db
Database instance.
param transaction
IDB transaction instance.
Upgrade schema to version 2 . Create an object store to host groups of calls and populate this store with the already existing recent calls data . param db Database instance . param transaction IDB transaction instance .
function upgradeSchemaVersion2(db, transaction, next) {
     { id: <String> (Primary key, hash created from number and date)
       number: <String>,
       contact: <String>,
       date: <Date>,
       type: <String>,
       retryCount: <Number> }
      'retryCount' is incremented when we store a call of the same 'type'
      and resetted to 1 otherwise.
      We store 'number' and 'contact' separatedly so we allow searches by
      these fields without being dependent of the contacts API.
    var groupsStore = db.createObjectStore(this._dbGroupsStore,
                                           { keyPath: 'id' });
     We create an index for 'groupId' in the object store hosting the
     actual calls. Each call belongs to a group indexed by id.
    var recentsStore = transaction.objectStore(this._dbRecentsStore);
    recentsStore.createIndex('groupId', 'groupId');
    next();
  }
function upgradeSchemaVersion2 ( db , transaction , next ) { var groupsStore = db . createObjectStore ( this . _dbGroupsStore , { keyPath : 'id' } ) ; var recentsStore = transaction . objectStore ( this . _dbRecentsStore ) ; recentsStore . createIndex ( 'groupId' , 'groupId' ) ; next ( ) ; }
Upgrade schema to version 2.
Upgrade schema to version 2 .
// This object store can be used to quickly construct a group view of the // recent calls database. Each entry looks like this: // // { id: <String> (Primary key, hash created from number and date) //   number: <String>, //   contact: <String>, //   date: <Date>, //   type: <String>, //   retryCount: <Number> } // //  'retryCount' is incremented when we store a call of the same 'type' //  and resetted to 1 otherwise. // //  We store 'number' and 'contact' separatedly so we allow searches by //  these fields without being dependent of the contacts API. // We create an index for 'groupId' in the object store hosting the // actual calls. Each call belongs to a group indexed by id.