INSERT with ON CONFLICT
This commit is contained in:
parent
d1ed9883db
commit
99c66e273b
1 changed files with 5 additions and 2 deletions
|
@ -49,10 +49,13 @@ impl Database {
|
|||
pub async fn store(&self, document_id: &str, document: &PersistedDocument) -> Result<()> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
INSERT OR REPLACE INTO
|
||||
INSERT INTO
|
||||
document (id, text, language)
|
||||
VALUES
|
||||
($1, $2, $3)"#,
|
||||
($1, $2, $3)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
text = excluded.text,
|
||||
language = excluded.language"#,
|
||||
)
|
||||
.bind(document_id)
|
||||
.bind(&document.text)
|
||||
|
|
Loading…
Add table
Reference in a new issue