When we do upsert, is there a way of knowing if th...
# orm-help
s
When we do upsert, is there a way of knowing if the object is created for the first time or is newly created?
r
Not a direct way, you can have fields like
createdAt
and
updatedAt
and then compare them to see if it’s a create or an update.
πŸ‘ 1
s
Ah, thanks. That could be the way. Just something from Django's ORM if it's possible to emulate in the future where you get the created value.
Copy code
obj, created = Person.objects.update_or_create(
    first_name='John', last_name='Lennon',
    defaults={'first_name': 'Bob'},
)
Anyways, Prisma has been real fun to use. πŸ™‚ Thanks.
πŸ”₯ 1
πŸ’― 1
r
It would be great if you could create a feature request here πŸ™‚
s
Done. Thank you. πŸ™‚
πŸ™Œ 1