I have the entity ID, but I need to check to make sure the entity record actually exists. I know I can just query the entity in some fashion similar to this:
SG_conn.find(‘Sequence’, filter, entity_fields)
with my entity fields being something like:
[‘id’, ‘is’, seq_id]
and check what it returns, but that assumes I know the entity type, and I was hoping for something more universal and wondered if there was a cleaner way to do it.
You’ll always need to know the entity-type as well as the id to find the entity.
I knew the ID was required, I just didn’t know of there was a “does exist” method somewhere that I didn’t know about.
So, just do a “find_one” and check to see if the return is empty?
Right, but you appeared to be asking if it was possible without the
entity-type, which isn’t possible.
“but that assumes I know the entity type”
The best approach is as you say, do a find_one and check if it returns empty.
Note: If you’re wanting to check a number of id’s in one batch, you’ll need to use find() and then check for an empty list instead.