1

idb.ObjectStore.putの新しい構文(r18915)に問題があります。誰か助けてもらえますか?以下の例では、次のようなエラーが発生します。

AsyncError: ‘Error:DataError: DOM IDBDatabase Exception 0’
Stack trace: #0 ObjectStore._put_2(file:///E:/b/build/slave/dartium-win-full-trunk/build/src/build/Release/obj/
global_intermediate/webkit/bindings/dart/indexed_db/ObjectStore.dart:141:3) #1
  ObjectStore.$dom_put(file:///E:/b/build/slave/dartium-win-full-trunc/build/src/build/Release/obj/
global_intermediate/webkit/bindings/dart/indexed_db/ObjectStore.dart:137:18) #2
  ObjectStore.put(file:///E:/b/build/slave/dartium-win-full-trunc/build/src/build/Release/obj/
global_intermediate/webkit/bindings/dart/indexed_db/ObjectStore.dart:9:27)

私が使用しているコードは機能していましたが、新しいリリース用に次のように変更されています:

Future fDbAddOrUpdateClient(String sKey1, ClassClientData clClientData) { 
  idb.Transaction oDbTxn         = ogDb1.transaction(sgStoreClient, 'readwrite');
  idb.ObjectStore oDbStoreClient = oDbTxn.objectStore(sgStoreClient);

  Completer completer = new Completer();
  var oDbReqPut = oDbStoreClient.put(
        {'sKey': sKey1,
         'sNameTitle'  : clClientData.sNameTitle, 
         'sNameFamily' : clClientData.sNameFamily,
         'sNameGiven1' : clClientData.sNameGiven1,
         'sNameGiven2' : clClientData.sNameGiven2
         })
         .then((val){
           completer.complete(val);
           return;
         })
         .catchError((e){
           window.alert("${e}");
           return;
         });
}
4

2 に答える 2

0

関数が返すことを指定する未来とは別に、(他のコメントで述べたように) 完成した値のみを返すと、未来の構文は正しく表示されます。エラー自体は、objectstore.put コマンドに渡されるデータが無効であることを実際に示しています。

IndexedDB の例外を参照してください。マップに渡されるデータを確認する必要がある場合があります。

于 2013-03-04T13:49:33.273 に答える
0

助けてくれてありがとう。主な問題は、データベースが開いていないか、ObjectStore が作成されていないなどの関連があるようですが、エラーは表示されません。

うまくいけば、次のコードがより良いコードになります (r19425):

  Future future = fDbAddOrUpdateClient(sKey, clClientData)
   .catchError((oError) => window.alert("${oError}"));
}

Future fDbAddOrUpdateClient(String sKey1, ClassClientData clClientData) { 
  idb.Transaction oDbTxn         = ogDb1.transaction(sgStoreClient, 'readwrite');
  idb.ObjectStore oDbStoreClient = oDbTxn.objectStore(sgStoreClient);

  return oDbStoreClient.put(fMapClient(sKey1, clClientData));
}
于 2013-03-07T04:59:03.343 に答える