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 @DocsEditable() | 7 @DocsEditable() |
8 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 8 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
9 @DomName('IDBDatabase.createObjectStore') | 9 @DomName('IDBDatabase.createObjectStore') |
10 @DocsEditable() | 10 @DocsEditable() |
11 ObjectStore createObjectStore(String name, | 11 ObjectStore createObjectStore(String name, |
12 {String keyPath, bool autoIncrement}) { | 12 {String keyPath, bool autoIncrement}) { |
13 var options = {}; | 13 var options = {}; |
14 if (keyPath != null) { | 14 if (keyPath != null) { |
15 options['keyPath'] = keyPath; | 15 options['keyPath'] = keyPath; |
16 } | 16 } |
17 if (autoIncrement != null) { | 17 if (autoIncrement != null) { |
18 options['autoIncrement'] = autoIncrement; | 18 options['autoIncrement'] = autoIncrement; |
19 } | 19 } |
20 | 20 |
21 return _createObjectStore(name, options); | 21 return _createObjectStore(name, options); |
22 } | 22 } |
23 | 23 |
24 $if DART2JS | |
25 Transaction transaction(storeName_OR_storeNames, String mode) { | 24 Transaction transaction(storeName_OR_storeNames, String mode) { |
26 if (mode != 'readonly' && mode != 'readwrite') { | 25 if (mode != 'readonly' && mode != 'readwrite') { |
27 throw new ArgumentError(mode); | 26 throw new ArgumentError(mode); |
28 } | 27 } |
29 | 28 |
30 // TODO(sra): Ensure storeName_OR_storeNames is a string or List<String>, | 29 // TODO(sra): Ensure storeName_OR_storeNames is a string or List<String>, |
31 // and copy to JavaScript array if necessary. | 30 // and copy to JavaScript array if necessary. |
32 | 31 |
33 // Try and create a transaction with a string mode. Browsers that expect a | 32 // Try and create a transaction with a string mode. Browsers that expect a |
34 // numeric mode tend to convert the string into a number. This fails | 33 // numeric mode tend to convert the string into a number. This fails |
(...skipping 21 matching lines...) Expand all Loading... |
56 | 55 |
57 Transaction transactionStores(DomStringList storeNames, String mode) { | 56 Transaction transactionStores(DomStringList storeNames, String mode) { |
58 if (mode != 'readonly' && mode != 'readwrite') { | 57 if (mode != 'readonly' && mode != 'readwrite') { |
59 throw new ArgumentError(mode); | 58 throw new ArgumentError(mode); |
60 } | 59 } |
61 return _transaction(storeNames, mode); | 60 return _transaction(storeNames, mode); |
62 } | 61 } |
63 | 62 |
64 @JSName('transaction') | 63 @JSName('transaction') |
65 Transaction _transaction(stores, mode) native; | 64 Transaction _transaction(stores, mode) native; |
66 $else | |
67 Transaction transaction(storeName_OR_storeNames, String mode) { | |
68 if (mode != 'readonly' && mode != 'readwrite') { | |
69 throw new ArgumentError("Invalid transaction mode $mode"); | |
70 } | |
71 var names; | |
72 if (storeName_OR_storeNames == null) { | |
73 throw new ArgumentError("stores may not be null in transaction"); | |
74 } else if (storeName_OR_storeNames is String || storeName_OR_storeNames is D
omStringList) { | |
75 names = storeName_OR_storeNames; | |
76 } else if (storeName_OR_storeNames is List<String>) { | |
77 names = convertDartToNative_List(storeName_OR_storeNames); | |
78 } else { | |
79 throw new ArgumentError("Invalid store(s) $store_Name_OR_storeNames"); | |
80 } | |
81 | |
82 return _blink.BlinkIDBDatabase.instance.transaction_Callback_2_(this, names,
mode); | |
83 } | |
84 | |
85 Transaction transactionList(List<String> storeNames, String mode) => transacti
on(storeNames, mode); | |
86 Transaction transactionStores(List<String> storeNames, String mode) => transac
tion(storeNames, mode); | |
87 Transaction transactionStore(String storeName, String mode) => transaction(sto
reName, mode); | |
88 $endif | |
89 | 65 |
90 $!MEMBERS} | 66 $!MEMBERS} |
OLD | NEW |