未捕获ydn.error.ArgumentException:要求在商店“contactRole”store.js第1284行找不到索引“Account _c,PrimaryContact__c”

时间:2015-05-12 11:19:22

标签: indexeddb ydn-db

我有以下内容:

ydbStorage = new ydn.db.Storage(dbName,schema);

/**
@param values - An array of keys . e.g. ['account1', 'city1']
@param index - An string of index value . e.g. 'account, city'
@description - Get records based on compound index. Remember that indexes are not created for boolean values
*/
var getRecordsOnCompoundIndex = function(store_name, index, values, success_callback, failure_callback) {
  console.log('Inside getRecordsOnCompoundIndex');
  if(!store_name || ! index || !values) {
      failure_callback();
  } else {
  var keyRange = ydn.db.KeyRange.only(values);
      ydbStorage.values(new ydn.db.IndexValueIterator(store_name, index, keyRange)).done(function(response) {
        if(!response){
            failure_callback();
        }else{
            success_callback(response);
        }
      });
  }
}

$scope.getAccountKeyContact = function() {
  var indexes = 'Account__c,PrimaryContact__c';
  var values = [accountId, "true"];
  ydbDatabase.getRecordsOnCompoundIndex('contactRole', indexes, values, function(records) {
    //console.log('KeyContact role is : ', records);

    ydbDatabase.getRecordOnId('contacts', records[0].Contact__c, function(record) {
      $scope.outlet.keyContact = record;
      $scope.outlet.keyContact.designation = records[0].Role__c;
      $scope.$apply();
    }, function() {
      console.log('Could not get KeyContact');
    });

  }, function() {
    console.log('Could not get contactRole Role');
  });
}

contactRole indexedDB store

尽管存在复合索引,但我收到以下错误。

未捕获ydn.error.ArgumentException:要求在商店“contactRole”中找不到索引“Account _c,PrimaryContact__c”

无法弄清楚出了什么问题。有什么建议。错误与行ydbDatabase.getRecordsOnCompoundIndex

有关

1 个答案:

答案 0 :(得分:0)

您确定复合索引为describe here吗?它应该是这样的:

var schema = {
store: [{
    name: 'contactRole',
    indexes: [{
      name: 'AccuntContact',
      keyPath: ['Account__c', 'PrimaryContact__c']
    }]
  }]
};