Метод openCursor
- @DomName('IDBObjectStore.openCursor')
Создаёт поток курсоров по записям в этом хранилище объектов.
Поток необходимо вручную продвигать, вызывая Cursor.next после каждого элемента или установив autoAdvance в значение true.
var cursors = objectStore.openCursor().listen(
(cursor) {
// ...some processing with the cursor
cursor.next(); // advance onto the next cursor.
},
onDone: () {
// called when there are no more cursors.
print('all done!');
});
Асинхронные операции, не связанные с текущей транзакцией, приведут к автоматическому подтверждению транзакции — вся обработка должна выполняться синхронно, за исключением дополнительных асинхронных запросов к текущей транзакции.
Исходный код
@DomName('IDBObjectStore.openCursor')
Stream<CursorWithValue> openCursor(
{key, KeyRange range, String direction, bool autoAdvance}) {
var key_OR_range = null;
if (key != null) {
if (range != null) {
throw new ArgumentError('Cannot specify both key and range.');
}
key_OR_range = key;
} else {
key_OR_range = range;
}
// TODO: try/catch this and return a stream with an immediate error.
var request;
if (direction == null) {
request = _openCursor(key_OR_range);
} else {
request = _openCursor(key_OR_range, direction);
}
return _cursorStreamFromResult(request, autoAdvance);
}
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-indexed_db/ObjectStore/openCursor.html