-
Notifications
You must be signed in to change notification settings - Fork 158
Support for ON CONFLICT #425
Comments
A typical |
Yes I would! Boolean options are preferable; I am actually in the middle of some reorganizing around statement generation so you may want to hold off for a day or so to avoid a different kind of conflict :) |
@tamlyn I just merged the big statement refactor down, so you're good to go on this! |
That's an awesome feature, is it in the roadmap? 🙂 I made a const upsert = async (table, collection) =>
aigle.eachSeries(collection, async data => {
const id = data.id
const instance = await table.findOne({ id })
return isNil(instance) ? table.insert(data) : table.update({ id }, data)
}) using it await upsert(db.customers, customersPlans)
await upsert(db.quotas, quotas)
await upsert(db.plans, plans) one thing, why is not possible use |
Massive doesn't have a "roadmap" as such. The goal has always been to cover ~90% of day-to-day database usage and make doing the remaining 10% with SQL as easy as possible; there's not much to get all project management over since that goal's been comfortably met for some time, and everything else is, functionally speaking, gravy. If you'd like to take a crack at generating a proper Can you open another issue for your custom id problem and clarify it a little more? |
Postgres 9.5 introduced the
ON CONFLICT
clause which enables upsert behavior.Would you be open to a PR to add support for this to Massive as an option on
insert
? Simplest solution would be to add a secondoptions
parameter. e.g.It should be possible to generate the rest of the
do update
clause automatically.Alternatively the options could be flags like
{ignoreConflict: true}
and{upsert: true}
respectively.As mentioned in #278 (comment) this this could also be used for
save
.The text was updated successfully, but these errors were encountered: