import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class ViewTableModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('ViewTable', 'viewTables', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'ViewTableFilter', 'ViewTableOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'ViewTable',
            fieldName: 'viewTables',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('ViewTable', 'viewTables', args.select, {
            where: args?.where,
        }, 'ViewTableFilter', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'ViewTable',
            fieldName: 'viewTables',
            document,
            variables,
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('ViewTable', 'viewTables', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'ViewTableFilter', 'ViewTableOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'ViewTable',
            fieldName: 'viewTable',
            document,
            variables,
            transform: (data) => ({
                viewTable: data.viewTables?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('ViewTable', 'createViewTable', 'viewTable', args.select, args.data, 'CreateViewTableInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'ViewTable',
            fieldName: 'createViewTable',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('ViewTable', 'updateViewTable', 'viewTable', args.select, args.where.id, args.data, 'UpdateViewTableInput', 'id', 'viewTablePatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'ViewTable',
            fieldName: 'updateViewTable',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('ViewTable', 'deleteViewTable', 'viewTable', {
            id: args.where.id,
        }, 'DeleteViewTableInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'ViewTable',
            fieldName: 'deleteViewTable',
            document,
            variables,
        });
    }
}
