Javascript 使用复合索引的查询中的游标顺序
我想知道在使用复合索引的查询中记录是如何排列的Javascript 使用复合索引的查询中的游标顺序,javascript,cursor,indexeddb,cursor-position,Javascript,Cursor,Indexeddb,Cursor Position,我想知道在使用复合索引的查询中记录是如何排列的 让我们考虑这个例子。 let objetStore = db.createObjectStore('article',{keyPath : 'id'}); objectStore.createIndex('userid-date',['userid','date_created']); db.transaction('article').objectStore('article').index('userid-date').openCursor(
让我们考虑这个例子。
let objetStore = db.createObjectStore('article',{keyPath : 'id'});
objectStore.createIndex('userid-date',['userid','date_created']);
db.transaction('article').objectStore('article').index('userid-date').openCursor(IDBKeyRange.bound([1,new Date(new Date() - 365*86400*1000)],[100,new Date()])).onsuccess = function(e){
};
上述查询中的记录是否按userid
或date\u created
排序?为什么?请参阅。基本上,索引首先按用户id排序,然后按创建日期排序,因为这是传递给createIndex方法的数组中属性的顺序
排序函数是indexedDB.cmp。这是indexedDB特有的自定义排序功能。您需要阅读indexedDB规范的大部分内容才能理解它。相关问题对其进行了部分总结