We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Currently, the user has to determine if the database had already stored a duplicated key:
let table = db.table(ARecord.self) if try table.where(\ARecord.id == record.id).count() > 0 { try table.update(record) } else { try table.insert(record) }
And apparently, the snippet above is low efficient and could not fully use the native SQL for INSERT ON CONFLICT.
INSERT ON CONFLICT
The new upsert() or a general save() function should simplify the above code to:
upsert()
save()
try table.save(record)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Proposal
Currently, the user has to determine if the database had already stored a duplicated key:
And apparently, the snippet above is low efficient and could not fully use the native SQL for
INSERT ON CONFLICT
.The new
upsert()
or a generalsave()
function should simplify the above code to:try table.save(record)
The text was updated successfully, but these errors were encountered: