[Pas2js] TJSIDBObjectStore.add() not working with a recordtype variable.....

Michael Van Canneyt michael at freepascal.org
Sat Sep 21 18:17:14 CEST 2019



On Fri, 20 Sep 2019, Pedro Pablo Oviedo Vera wrote:

> Hello people!,
> Im facing this problem:
>
> var
>  fTransPeliculas: TJSIDBTransaction;
>  fTransAlmacen  : TJSIDBObjectStore;
>  fSolicitud     : TJSIDBRequest;
> begin
>
>  (......)
>
>  fTransPeliculas   :=  gMyDB.transaction(['peliculas'],'readwrite');
>  fTransAlmacen     :=  fTransPeliculas.objectStore('peliculas');
>
>  gInfo.clave       :=  gedtClave.value;
>  gInfo.anno        :=  gedtFecha.value;
>  gInfo.texto       :=  gedtTexto.value;
>
>  fSolicitud        := fTransAlmacen.add(gInfo,'clave');
>
> but from browser consola I recieve the message:
>       DataError: Data provided to an operation does not meet requirements.
>
> but when use this alternative....
>  asm
>     fSolicitud =
> fTransAlmacen.add({id:$mod.gInfo.clave,nombre:$mod.gInfo.texto,fecha:$mod.gInfo.anno});
>  end;
>
> everything works!!!!
> perhaps fSolicitud        := fTransAlmacen.add(gInfo,'clave'); is
> incorrepts ...then how it will be OK?

first of all, you are doing things very differently
- your asm code does not provide a key, your pascal code does.
- the structure of the object you are saving is very different.

Secondly, to know why it goes wrong, we need to know what is the definition of the
object store.

Maybe this answers your question:
https://stackoverflow.com/questions/36016862/indexeddb-dataerror-data-provided-to-an-operation-does-not-meet-requirements

Michael.


More information about the Pas2js mailing list