I have the following:
我有以下内容:
ydbStorage = new ydn.db.Storage(dbName, schema);
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');
});
}
I am getting the following error in spite of the compound index being present.
尽管存在复合索引,但我收到以下错误。
Uncaught ydn.error.ArgumentException: require index "Account__c,PrimaryContact__c" not found in store "contactRole"
未捕获ydn.error.ArgumentException:要求在商店“contactRole”中找不到索引“Account _c,PrimaryContact__c”
Can't figure out what is wrong. Any suggestions. The error is with the line ydbDatabase.getRecordsOnCompoundIndex
无法弄清楚出了什么问题。有什么建议。错误与行ydbDatabase.getRecordsOnCompoundIndex有关
1 个解决方案
#1
Are you sure you have compound index as describe here. It should be something like:
你确定你有复合索引,如下所述。它应该是这样的:
var schema = {
store: [{
name: 'contactRole',
indexes: [{
name: 'AccuntContact',
keyPath: ['Account__c', 'PrimaryContact__c']
}]
}]
};
#1
Are you sure you have compound index as describe here. It should be something like:
你确定你有复合索引,如下所述。它应该是这样的:
var schema = {
store: [{
name: 'contactRole',
indexes: [{
name: 'AccuntContact',
keyPath: ['Account__c', 'PrimaryContact__c']
}]
}]
};