import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class DbUsageModuleModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('DbUsageModule', 'dbUsageModules', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'DbUsageModuleFilter', 'DbUsageModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'DbUsageModule',
            fieldName: 'dbUsageModules',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('DbUsageModule', 'dbUsageModules', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'DbUsageModuleFilter', 'DbUsageModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'DbUsageModule',
            fieldName: 'dbUsageModule',
            document,
            variables,
            transform: (data) => ({
                dbUsageModule: data.dbUsageModules?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('DbUsageModule', 'dbUsageModules', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'DbUsageModuleFilter', 'DbUsageModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'DbUsageModule',
            fieldName: 'dbUsageModule',
            document,
            variables,
            transform: (data) => ({
                dbUsageModule: data.dbUsageModules?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('DbUsageModule', 'createDbUsageModule', 'dbUsageModule', args.select, args.data, 'CreateDbUsageModuleInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'DbUsageModule',
            fieldName: 'createDbUsageModule',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('DbUsageModule', 'updateDbUsageModule', 'dbUsageModule', args.select, args.where.id, args.data, 'UpdateDbUsageModuleInput', 'id', 'dbUsageModulePatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'DbUsageModule',
            fieldName: 'updateDbUsageModule',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('DbUsageModule', 'deleteDbUsageModule', 'dbUsageModule', {
            id: args.where.id,
        }, 'DeleteDbUsageModuleInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'DbUsageModule',
            fieldName: 'deleteDbUsageModule',
            document,
            variables,
        });
    }
}
