lastmatador Posted October 20, 2022 Report Share Posted October 20, 2022 Hello! 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. Thanks! Link to comment Share on other sites More sharing options...
Patrick Boucher ftrack Posted October 28, 2022 Report Share Posted October 28, 2022 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 ).default_projections; const response = await session.query(`select ${projection.join(',')} from ${entityType} limit 1`); console.log(response); 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! Cheers, Patrick Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now