dist/find-one.js
function findOne(repository, options) {
    const entityPrimaryKeyColumn = lodash_1.find(repository.metadata.columns, (columnMetadata) => columnMetadata.isPrimary).propertyName;
    const entityColumns = repository.metadata.columns.map((columnMetadata) => columnMetadata.propertyName);
    const entityManyToOneOrOneToOneRelationColumns = repository
        .metadata
        .relations
        .filter((relationMetadata) => relationMetadata.relationType === 'many-to-one' || relationMetadata.relationType === 'one-to-one')
        .map((relationMetadata) => relationMetadata.propertyName);
    const entityUniqueColumns = repository
        .metadata
        .columns
        .filter((columnMetadata) => columnMetadata.isUnique)
        .map((columnMetadata) => columnMetadata.propertyName);
    return function (source, args, context, info) {
        return __awaiter(this, void 0, void 0, function* () {
            const selectedColumns = Object.keys(graphqlFields(info));
            const selectQueryBuilder = repository.createQueryBuilder(repository.metadata.name.toLowerCase());
            /** Select **/
            const selectFactory = new select_factory_1.SelectFactory(selectQueryBuilder);
            selectFactory
                .select(selectedColumns.filter((select) => entityColumns.includes(select)));
            /** Where **/
            const filter = Object
                .keys(args)
                .filter((argName) => entityUniqueColumns.includes(argName) || argName === entityPrimaryKeyColumn)
                .reduce((filteredArgs, argName) => {
                filteredArgs[argName] = args[argName];
                return filteredArgs;
            }, {});
            const whereFactory = new where_factory_1.WhereFactory(selectQueryBuilder, entityManyToOneOrOneToOneRelationColumns);
            whereFactory
                .where(filter);
            /** Joins **/
            const joinsFactory = new joins_factory_1.JoinsFactory(selectQueryBuilder);
            joinsFactory
                .join(selectedColumns
                .filter((select) => entityManyToOneOrOneToOneRelationColumns.includes(select))
                .reduce((selectedRelationColumns, selectedRelationColumn) => {
                selectedRelationColumns[selectQueryBuilder.alias] = selectedRelationColumn;
                return selectedRelationColumns;
            }, {}))
                .join(whereFactory.selectedManyToOneOrOneToOneRelationColumns);
            /** Extend **/
            if (lodash_1.get(options, 'extend')) {
                yield options.extend(selectQueryBuilder);
            }
            /** Execute get many method **/
            return yield selectQueryBuilder.getOne();
        });
    };
}
function findOne(repository, options) {
    const entityPrimaryKeyColumn = lodash_1.find(repository.metadata.columns, (columnMetadata) => columnMetadata.isPrimary).propertyName;
    const entityColumns = repository.metadata.columns.map((columnMetadata) => columnMetadata.propertyName);
    const entityManyToOneOrOneToOneRelationColumns = repository
        .metadata
        .relations
        .filter((relationMetadata) => relationMetadata.relationType === 'many-to-one' || relationMetadata.relationType === 'one-to-one')
        .map((relationMetadata) => relationMetadata.propertyName);
    const entityUniqueColumns = repository
        .metadata
        .columns
        .filter((columnMetadata) => columnMetadata.isUnique)
        .map((columnMetadata) => columnMetadata.propertyName);
    return function (source, args, context, info) {
        return __awaiter(this, void 0, void 0, function* () {
            const selectedColumns = Object.keys(graphqlFields(info));
            const selectQueryBuilder = repository.createQueryBuilder(repository.metadata.name.toLowerCase());
            /** Select **/
            const selectFactory = new select_factory_1.SelectFactory(selectQueryBuilder);
            selectFactory
                .select(selectedColumns.filter((select) => entityColumns.includes(select)));
            /** Where **/
            const filter = Object
                .keys(args)
                .filter((argName) => entityUniqueColumns.includes(argName) || argName === entityPrimaryKeyColumn)
                .reduce((filteredArgs, argName) => {
                filteredArgs[argName] = args[argName];
                return filteredArgs;
            }, {});
            const whereFactory = new where_factory_1.WhereFactory(selectQueryBuilder, entityManyToOneOrOneToOneRelationColumns);
            whereFactory
                .where(filter);
            /** Joins **/
            const joinsFactory = new joins_factory_1.JoinsFactory(selectQueryBuilder);
            joinsFactory
                .join(selectedColumns
                .filter((select) => entityManyToOneOrOneToOneRelationColumns.includes(select))
                .reduce((selectedRelationColumns, selectedRelationColumn) => {
                selectedRelationColumns[selectQueryBuilder.alias] = selectedRelationColumn;
                return selectedRelationColumns;
            }, {}))
                .join(whereFactory.selectedManyToOneOrOneToOneRelationColumns);
            /** Extend **/
            if (lodash_1.get(options, 'extend')) {
                yield options.extend(selectQueryBuilder);
            }
            /** Execute get many method **/
            return yield selectQueryBuilder.getOne();
        });
    };
}
function findOne ( repository , options ) { const entityPrimaryKeyColumn = lodash_1 . find ( repository . metadata . columns , ( columnMetadata ) => columnMetadata . isPrimary ) . propertyName ; const entityColumns = repository . metadata . columns . map ( ( columnMetadata ) => columnMetadata . propertyName ) ; const entityManyToOneOrOneToOneRelationColumns = repository . metadata . relations . filter ( ( relationMetadata ) => relationMetadata . relationType === 'many-to-one' || relationMetadata . relationType === 'one-to-one' ) . map ( ( relationMetadata ) => relationMetadata . propertyName ) ; const entityUniqueColumns = repository . metadata . columns . filter ( ( columnMetadata ) => columnMetadata . isUnique ) . map ( ( columnMetadata ) => columnMetadata . propertyName ) ; return function ( source , args , context , info ) { return __awaiter ( this , void 0 , void 0 , function * ( ) { const selectedColumns = Object . keys ( graphqlFields ( info ) ) ; const selectQueryBuilder = repository . createQueryBuilder ( repository . metadata . name . toLowerCase ( ) ) ; /** Select **/ const selectFactory = new select_factory_1 . SelectFactory ( selectQueryBuilder ) ; selectFactory . select ( selectedColumns . filter ( ( select ) => entityColumns . includes ( select ) ) ) ; /** Where **/ const filter = Object . keys ( args ) . filter ( ( argName ) => entityUniqueColumns . includes ( argName ) || argName === entityPrimaryKeyColumn ) . reduce ( ( filteredArgs , argName ) => { filteredArgs [ argName ] = args [ argName ] ; return filteredArgs ; } , { } ) ; const whereFactory = new where_factory_1 . WhereFactory ( selectQueryBuilder , entityManyToOneOrOneToOneRelationColumns ) ; whereFactory . where ( filter ) ; /** Joins **/ const joinsFactory = new joins_factory_1 . JoinsFactory ( selectQueryBuilder ) ; joinsFactory . join ( selectedColumns . filter ( ( select ) => entityManyToOneOrOneToOneRelationColumns . includes ( select ) ) . reduce ( ( selectedRelationColumns , selectedRelationColumn ) => { selectedRelationColumns [ selectQueryBuilder . alias ] = selectedRelationColumn ; return selectedRelationColumns ; } , { } ) ) . join ( whereFactory . selectedManyToOneOrOneToOneRelationColumns ) ; /** Extend **/ if ( lodash_1 . get ( options , 'extend' ) ) { yield options . extend ( selectQueryBuilder ) ; } /** Execute get many method **/ return yield selectQueryBuilder . getOne ( ) ; } ) ; } ; }
Method to find the entity record.

@param {Repository<Entity>} repository
@param {FindOneOptions<Entity>} options
@returns {(source, args, context, info) => Promise<Entity>}
Method to find the entity record .