The Platter API is structured as a Graph of objects linking each other. The API offers a relationship query mechanism that allows serialising multiple objects in a single request.

Objects in Plattar can have one-to-many, many-to-many and many-to-one based relationships.

Performing relation queries naturally increases the payload size of the request for the benefit of performing fewer requests to the API.

Get Scenes from Project
This example shows how to access Scene objects related to the Project
const {
	Project,
	Scene
} = require('@plattar/plattar-api');

const project = new Project('your-project-id');

project.get().then((proj) => {
  	// .filter() function returns an array of Scene objects
	const scenes = proj.relationships.filter(Scene);

	// loop through scenes
	scenes.forEach((scene) => {});
}).catch((error) => {
	console.error(error);
});
Get Scenes from Project with ID
This example shows how to access specific Scene with id related to the Project
const {
	Project,
	Scene
} = require('@plattar/plattar-api');

const project = new Project('your-project-id');

project.get().then((proj) => {
  	// .filter() function returns an array of Scene objects
  	// that match the ID of 'your-scene-id'
	const scenes = proj.relationships.filter(Scene, 'your-scene-id');

	// loop through scenes - when an ID is provided this will
  	// typically return an array of length 1 (or empty)
	scenes.forEach((scene) => {});
}).catch((error) => {
	console.error(error);
});
Find a Scene from Project with ID
This example shows how to find a specific Scene with id related to the Project
const {
	Project,
	Scene
} = require('@plattar/plattar-api');

const project = new Project('your-project-id');

project.get().then((proj) => {
  	// .find() function returns a single Scene object
  	// that match the ID of 'your-scene-id'
	const scene = proj.relationships.find(Scene, 'your-scene-id');
  
  	if (scene) {
    	// do something with scene
  	}
}).catch((error) => {
	console.error(error);
});