Bom dia,
estou recebendo um erro ao testar meu NegociacaoDao.js no Chrome (versão 66.0.3359.181), porém funciona normalmente no Firefox!
Comando:
ConnectionFactory.getConnection().then(connection => new NegociacaoDao(connection).adiciona(new Negociacao(new Date(), 7, 100)));
Erro:
Uncaught (in promise) DOMException: Failed to execute 'add' on 'IDBObjectStore': The object store uses out-of-line keys and has no key generator and the key parameter was not provided.
at Promise (http://localhost:3000/js/app/dao/NegociacaoDao.js:16:18)
at new Promise (<anonymous>)
at NegociacaoDao.adiciona (http://localhost:3000/js/app/dao/NegociacaoDao.js:11:16)
at ConnectionFactory.getConnection.then.connection (<anonymous>:1:84)
NegociacaoDao.js:
class NegociacaoDao {
constructor(connection) {
this._connection = connection;
this._store = 'negociacoes';
}
adiciona(negociacao) {
return new Promise((resolve, reject) => {
let request = this._connection
.transaction([this._store],'readwrite')
.objectStore(this._store)
.add(negociacao);
request.onsuccess = evento => {
resolve();
};
request.onerror = evento => {
console.log(evento.target.error);
reject('nao foi possivel adicionar a negociacao');
};
});
}
}