AWS Amplify: query multiple models from function handler

Discussão em 'Angular' iniciado por victim, Junho 22, 2025.

  1. victim

    victim Guest

    I want to combine in a response, various attributes from different (non-related-)tables.

    I'm using amplify with an Angular 19 project, my data is being stored in DynamoDB tables.

    Here's an example of what I wanna do:

    ./amplify/data/resource.ts:

    import { type ClientSchema, a, defineData } from '@aws-amplify/backend';
    import { fetchManyModels } from './queries/fetch-many-models/resource';

    const schema = a.schema({
    FetchManyModels: a
    .query()
    .returns(a.string())
    .handler(a.handler.function(fetchManyModels)),
    ...


    ./amplify/data/queries/fetch-many-models/handler.ts:

    import type { Schema } from "../../resource"
    import { env } from "$amplify/env/fetch-many-models"

    export const handler: Schema["FetchManyModels"]["functionHandler"] = async (event) => {
    const model1 = data_from_somewhere.MyModel_1;
    const model2 = data_from_somewhere.MyModel_2;

    return model1.tostring() + model2.toString();
    }

    Continue reading...

Compartilhe esta Página