Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned. #6411

Closed
BrainBuzzer opened this issue Apr 6, 2017 · 3 comments

Comments

@BrainBuzzer
Copy link

Issue

I've got a piece of code to update my data. But I've not been able to do so because I keep getting this one error:

pouchdb.min.js:8 Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned.

I've tried using upsert plugin, regular put with no luck.

When I create data, I do not use put. I use post instead without providing any ID field. Is it because of this?

Info

  • Environment: Electron
  • Platform: Chrome
  • Adapter: IndexedDB
  • Server: None

Reproduce

For creating new document:

db.post({
	"name": document.getElementById('shop_name').value,
	"owner": document.getElementById('owner_name').value,
	"mobile": document.getElementById('mobile_no').value,
	"reg_date": document.getElementById('datepicker').value,
	"exp_date": expiry._d
})

For Updating document:

db.upsert(id, doc => {
  doc.exp_date = moment(date).add(parseInt(document.getElementById('ext_date').value), 'years');
  return doc;
}).then(res => console.log(res)).catch(err => console.log(err));
@karlwestin
Copy link
Contributor

I believe this is because you're putting a moment object on the exp_date key in your update function. PouchDB can not serialize those and i was able to repro your error in this JSBin http://jsbin.com/seyukuseku/edit?js,output

Can you try convert it to a timestamp or JSON string, for example with moment().valueOf() ?

@BrainBuzzer
Copy link
Author

Oops. Looks like my mistake. Instead of simply resolving date, I was storing entire moment object. Thanks.

@karlwestin
Copy link
Contributor

No worries, i've done the same thing a few times!
Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants