import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class TableGrantModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('TableGrant', 'tableGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'TableGrantFilter', 'TableGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'TableGrant',
            fieldName: 'tableGrants',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('TableGrant', 'tableGrants', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'TableGrantFilter', 'TableGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'TableGrant',
            fieldName: 'tableGrant',
            document,
            variables,
            transform: (data) => ({
                tableGrant: data.tableGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('TableGrant', 'tableGrants', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'TableGrantFilter', 'TableGrantOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'TableGrant',
            fieldName: 'tableGrant',
            document,
            variables,
            transform: (data) => ({
                tableGrant: data.tableGrants?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('TableGrant', 'createTableGrant', 'tableGrant', args.select, args.data, 'CreateTableGrantInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'TableGrant',
            fieldName: 'createTableGrant',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('TableGrant', 'updateTableGrant', 'tableGrant', args.select, args.where.id, args.data, 'UpdateTableGrantInput', 'id', 'tableGrantPatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'TableGrant',
            fieldName: 'updateTableGrant',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('TableGrant', 'deleteTableGrant', 'tableGrant', {
            id: args.where.id,
        }, 'DeleteTableGrantInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'TableGrant',
            fieldName: 'deleteTableGrant',
            document,
            variables,
        });
    }
}
