Can all objects be defined as "slave" objects in the configuration?


Answer:

Yes, you can technically configure all objects in your system as "slaves". This setup necessitates an implicit external master or an external process that supplies the necessary IDs for filtering.

When all objects are set as "slaves" without an explicit "master," there is no inherent mechanism to specify which records to fetch. Slave objects rely on external IDs (such as customer or order IDs) provided by another process or query. These IDs are essential for filtering and determining which records the slave objects retrieve, typically based on the outputs from a master object's query.

Example export.json for an all-slave configuration:

{
    "objects": [
        {
            "query": "SELECT Id FROM Account WHERE Id IN :providedAccountIds",
            "externalId": "Name",
            "operation": "Upsert",
            "master": false
        },
        {
            "query": "SELECT Id, AccountId FROM Contact WHERE AccountId IN :providedAccountIds",
            "externalId": "LastName",
            "operation": "Upsert",
            "master": false
        },
        {
            "query": "SELECT Id, AccountId FROM Opportunity WHERE AccountId IN :providedAccountIds",
            "externalId": "Name",
            "operation": "Upsert",
            "master": false
        }
    ]
}

The following configuration will fail to fetch data as no slave object has explicit record filtering provided:

{
    "objects": [
        {
            "query": "SELECT Id FROM Account",
            "externalId": "Name",
            "operation": "Upsert",
            "master": false
        },
        {
            "query": "SELECT Id, AccountId FROM Contact",
            "externalId": "LastName",
            "operation": "Upsert",
            "master": false
        },
        {
            "query": "SELECT Id, AccountId FROM Opportunity",
            "externalId": "Name",
            "operation": "Upsert",
            "master": false
        }
    ]
}
Last updated on 18th Apr 2024