| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 7 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 8 @DomName('IDBIndex.count') | 8 @DomName('IDBIndex.count') |
| 9 Future<int> count([key_OR_range]) { | 9 Future<int> count([key_OR_range]) { |
| 10 try { | 10 try { |
| 11 var request; | 11 var request = _count(key_OR_range); |
| 12 if (key_OR_range != null) { | |
| 13 request = _count(key_OR_range); | |
| 14 } else { | |
| 15 request = _count(); | |
| 16 } | |
| 17 return _completeRequest(request); | 12 return _completeRequest(request); |
| 18 } catch (e, stacktrace) { | 13 } catch (e, stacktrace) { |
| 19 return new Future.error(e, stacktrace); | 14 return new Future.error(e, stacktrace); |
| 20 } | 15 } |
| 21 } | 16 } |
| 22 | 17 |
| 23 @DomName('IDBIndex.get') | 18 @DomName('IDBIndex.get') |
| 24 Future get(key) { | 19 Future get(key) { |
| 25 try { | 20 try { |
| 26 var request = _get(key); | 21 var request = _get(key); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 53 bool autoAdvance}) { | 48 bool autoAdvance}) { |
| 54 var key_OR_range = null; | 49 var key_OR_range = null; |
| 55 if (key != null) { | 50 if (key != null) { |
| 56 if (range != null) { | 51 if (range != null) { |
| 57 throw new ArgumentError('Cannot specify both key and range.'); | 52 throw new ArgumentError('Cannot specify both key and range.'); |
| 58 } | 53 } |
| 59 key_OR_range = key; | 54 key_OR_range = key; |
| 60 } else { | 55 } else { |
| 61 key_OR_range = range; | 56 key_OR_range = range; |
| 62 } | 57 } |
| 63 var request; | 58 var request = _openCursor(key_OR_range, direction); |
| 64 if (direction == null) { | |
| 65 request = _openCursor(key_OR_range); | |
| 66 } else { | |
| 67 request = _openCursor(key_OR_range, direction); | |
| 68 } | |
| 69 return ObjectStore._cursorStreamFromResult(request, autoAdvance); | 59 return ObjectStore._cursorStreamFromResult(request, autoAdvance); |
| 70 } | 60 } |
| 71 | 61 |
| 72 /** | 62 /** |
| 73 * Creates a stream of cursors over the records in this object store. | 63 * Creates a stream of cursors over the records in this object store. |
| 74 * | 64 * |
| 75 * See also: | 65 * See also: |
| 76 * | 66 * |
| 77 * * [ObjectStore.openCursor] | 67 * * [ObjectStore.openCursor] |
| 78 */ | 68 */ |
| 79 Stream<Cursor> openKeyCursor({key, KeyRange range, String direction, | 69 Stream<Cursor> openKeyCursor({key, KeyRange range, String direction, |
| 80 bool autoAdvance}) { | 70 bool autoAdvance}) { |
| 81 var key_OR_range = null; | 71 var key_OR_range = null; |
| 82 if (key != null) { | 72 if (key != null) { |
| 83 if (range != null) { | 73 if (range != null) { |
| 84 throw new ArgumentError('Cannot specify both key and range.'); | 74 throw new ArgumentError('Cannot specify both key and range.'); |
| 85 } | 75 } |
| 86 key_OR_range = key; | 76 key_OR_range = key; |
| 87 } else { | 77 } else { |
| 88 key_OR_range = range; | 78 key_OR_range = range; |
| 89 } | 79 } |
| 90 var request; | 80 var request = _openKeyCursor(key_OR_range, direction); |
| 91 if (direction == null) { | |
| 92 request = _openKeyCursor(key_OR_range); | |
| 93 } else { | |
| 94 request = _openKeyCursor(key_OR_range, direction); | |
| 95 } | |
| 96 return ObjectStore._cursorStreamFromResult(request, autoAdvance); | 81 return ObjectStore._cursorStreamFromResult(request, autoAdvance); |
| 97 } | 82 } |
| 98 | 83 |
| 99 $!MEMBERS | 84 $!MEMBERS |
| 100 } | 85 } |
| OLD | NEW |