Is there a way to block an upsert based on a key? ...
# community-help
d
Is there a way to block an upsert based on a key? I’m adding
updated_at_unix
in my document schema, and I’d love it if typesense would just know not to upsert the request if the ‘new’ update has an older
updated_at_unix
value.
j
d
oh…do i understand correctly that if my document has an
id
I still need the
filter_by
to include the
id:={myDocument.id}?;
j
No, if your document has an ID, then you can use the batch import endpoint to just send the docs with the id field and fields that need to be updated
If you need to do something like "UPDATE these records, that match this condition" without specifying an ID, that's when you use update by query
d
oh i see…but I want to handle the case where I only want to update the record, if the document I’m trying to put in the db has a value of the updated_at_unix field value that is greater than the one already existing in the DB, but I only want it to be for that one record. I’m guessing then it’s more performant to first get the record and then upsert?
I guess i could instead store that attribute in the database xD
oh wait….that’s already there because I have an updatedAt field ….so whenever i get an sqs message i check in the db first. Sorry I think I answered my own question
😄 1