You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.
Many document DBs with an HTTP API (e.g. RavenDB) implement PUT semantics for saving a document. I like the way this is handled in massive for tables (save doing an upsert), but for documents the API looks at the existence of a primary key column to determine whether an insert or update should be performed.
Can't we have saveDoc perform an upsert as well? This would keep the API similar. We could have separate insert/update methods as well.
Apparently I was wrong about the table vs. document table API, both just check for existence of an id column. Is there any way to force massive-js to do an upsert of a document with a primary key already specified?
Not through the table API, no. With 9.5 it should be possible to have save and saveDoc generate INSERT... ON CONFLICT ($pk) DO UPDATE instead of testing the primary key up front, but since that's an existing API call we'd have to implement some sort of option to turn it on so as not to break those functions for previous versions of Postgres.
If you're on 9.5 and you need to upsert something with a (potential) primary key, you should be able to cobble something together using the ON CONFLICT clause in a script file. That may or may not be more trouble than it's worth, though.
Many document DBs with an HTTP API (e.g. RavenDB) implement PUT semantics for saving a document. I like the way this is handled in massive for tables (
save
doing an upsert), but for documents the API looks at the existence of a primary key column to determine whether an insert or update should be performed.Can't we have
saveDoc
perform an upsert as well? This would keep the API similar. We could have separate insert/update methods as well.By the way:
https://github.com/robconery/massive-js/blob/master/lib/document_table.js#L71 declares an
updateDocSync
method, but never actually defines theupdateDoc
method that it should wrap.The text was updated successfully, but these errors were encountered: