2013-11-02 3 views
0

다음 코드는 내부 Dartium Exception을 발생시킵니다.다트 indexed_db put() 오류

<!DOCTYPE html> 

<html> 
<head> 
    <script type="application/dart"> 

    import 'dart:html'; 
    import 'dart:indexed_db'; 
    import 'dart:math'; 

    Random random = new Random(); 

    void main() { 
     window.indexedDB.open('myDB', version: 1, onUpgradeNeeded: _initDB).then((Database db) { 
     Transaction transaction = db.transaction('myStore', 'readwrite'); 
     ObjectStore objectStore = transaction.objectStore('myStore'); 
     Map data = { 
      'id': 'id' + random.nextInt(1000).toString(), 
      'name': 'name' + random.nextInt(1000).toString() 
     }; 
     objectStore.put(data); 
     }); 
    } 

    void _initDB(VersionChangeEvent e) { 
     (e.target as Request).result.createObjectStore('myStore'); 
    } 

    </script> 
    <script src="packages/browser/dart.js"></script> 
</head> 
</html> 

나는 http://www.dartbug.com/14256에 문제를 제기하지만, 어쩌면 뭔가 내 코드에서 잘못?

+0

오류에 대한 추가 정보를 제공해 줄 수 있습니까? –

+0

예, 여기 있습니다 http://www.dartbug.com/14256 – Leksat

+0

MAP의 종류는 무엇입니까? 그게 문제가 될 것입니다. 아마지도 개체를 제대로 직렬화 할 수 없습니다. –

답변

1

이 버그는 오류임을 나타내며 오류 메시지가 유용합니다. (

void _initDB(VersionChangeEvent e) { 
    (e.target as Request).result.createObjectStore('myStore', autoIncrement: true); 
} 

하지만 당신은 새로운 구조가 작동하려면 설정에서 브라우저에서 데이터를 삭제해야합니다 다음을 시도

Uncaught Error: DataError: The object store uses out-of-line keys and has no key generator and the key parameter was not provided.

0

: 그것은 더 유용한 메시지를보고 안 db 버전 번호를 늘릴 수도 있습니다).