DEV Community

Cover image for 🚀 Deep populate in API Maker
API Maker®
API Maker®

Posted on • Edited on

4 2 1

🚀 Deep populate in API Maker

  • Populate data from the multiple collection, databases or instances we use deep in the request payload.

  • We can provide deep information at two places:

simple deep

Here,

  • s_key = Source table field name
  • t_col = Target table name
  • t_key = Target table field name
  • t_instance = The instance name in which target table is present.
  • t_db = The database name in which the target table is present.
{
    "find": {
        "owner_id": 1
    },
    "deep": [
        {
            "s_key": "owner_id",
            "t_instance": "mysql",
            "t_db": "inventory",
            "t_col": "customers",
            "t_key": "customer_id"
        }
    ]
} 
Enter fullscreen mode Exit fullscreen mode

Add deep information in schema

  • Set instance, database, collection, and column in schema of the collection and provide only 's_key'(source key) in the deep to get deep data.

Request Payload

{
    "deep": [
        {
            "s_key": "owner_id"
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

Set deep for multiple fields

  • You can set deep inheritance using dot.

Request Payload

{
    "deep": [
        {
            "s_key": "owner_id"
        },
        {
            "s_key": "owner_id.shipping_id"
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

Deep inheritance

  • Write 'deep' in to the 'deep' and you will get inherited data.

Request Payload

{
    "deep": [
        {
            "s_key": "price",
            "t_col": "orders",
            "t_key": "total",
            "select": "pincode",
            "deep": [
                {
                    "s_key": "shipping_id",
                    "t_col": "customers",
                    "t_key": "shipping_id",
                    "select": "phone"
                },
                {
                    "s_key": "shipping_id.pincode",
                    "t_col": "orders",
                    "t_key": "pincode"
                }
            ]
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

Circular dependency

  • API Maker automatically handle the circular dependency so you do not need to take care of it.

Request Payload

{
    "deep": [
        {
            "s_key": "owner_id",
            "t_col": "customers",
            "t_key": "customer_id",
            "deep": [
                {
                    "s_key": "customer_id",
                    "t_col": "products",
                    "t_key": "owner_id",
                    "select": "owner_id",
                    "deep": [
                        {
                            "s_key": "owner_id",
                            "t_col": "customers",
                            "t_key": "customer_id",
                            "select": "customer_id"
                        }
                    ]
                }
            ]
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

To get more information about API Maker APIs please refer API Maker documentation.

API Maker deep feature video.

Websites
https://apimaker.dev

Follow on twitter
https://twitter.com/api_maker

Linked In
https://www.linkedin.com/company/api-maker

API Maker Youtube channel
https://www.youtube.com/@api_maker

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up