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

Update is not creating a new one and throwing an error #649

Closed
umutzd opened this issue Jan 26, 2018 · 2 comments
Closed

Update is not creating a new one and throwing an error #649

umutzd opened this issue Jan 26, 2018 · 2 comments
Labels

Comments

@umutzd
Copy link

umutzd commented Jan 26, 2018

I use update to add/update to sync a bulk of documents in a collection. But it throws an error:

Error: Trying to update unsynced document. Please save the document first by using insert() or addMany()

I get a huge data and assign this data to a specific collection. I use collection.update() method to do this. Problem is, if not found, is not creating a new one. Is there a way to do this? Or is there a known workaround?

@obeliskos
Copy link
Collaborator

If your docs have not yet been inserted into loki database and do not have a $loki id, you need to insert them first.

Loki does not (yet?) have upserts but this has been requested in #158. I suppose any upsert functionality (in LokiJS or LokiJS2) could allow keying off $loki or unique indices.

@stale
Copy link

stale bot commented Jul 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 13, 2018
@stale stale bot closed this as completed Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants