Skip to content

Insert if it doesn't exist, otherwise update #442

Answered by msiemens
eliluong asked this question in Q&A
Discussion options

You must be logged in to vote

@eliluong This sounds like the upsert operator: https://tinydb.readthedocs.io/en/latest/usage.html#upserting-data

Basically, you pass a query and a document. If the query matches any document that's already in the database, it will update it using the document you gave it. If there is no result, it will insert the provided document as a new one.

Does that work for you?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@eliluong
Comment options

Answer selected by eliluong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants