Jump to content

how to select whole entity in ftrack javascript api?


Recommended Posts


well, in python api I can get entity object like this:

entity_obj = session.query("Task where id is {some_id}").first()

Can I do something like that in javascript api to get whole object? Not only separate fields, like id, name or whatever...

I ask this, because to create some entities I have to put whole object to the data argument of create function.


Link to comment
Share on other sites

Hi @lastmatador,

The Python automatically fetches default projections for you. You have to manually specify the projections you want to load with the Javascript API. You can use the default projections from the schema as follows:

const entityType = 'Task'
const projection = session.schemas.find(
  (schema) => schema.id === entityType

const response = await session.query(`select ${projection.join(',')} from ${entityType} limit 1`);

The schema also has a list of properties for the entity type, so you could use that list to extract all the property names if you wanted to load _everything_ instead of just the default ones.

I hope this helps!


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...