Search code examples
javascriptnode.jsdatabasetypescripttypeorm

Type 'number' has no properties in common with type 'FindOneOptions<Client>'


enter image description here

While creating a findOne request using typeorm i get this error, HELP!


Solution

  • According to the TypeORM docs you need to call findOne like this (assuming clientId is also the name of the column in the Client table).

    const client = await Client.findOne({
        where: {
            clientId: clientId
        }
    });
    

    The error message is telling you that it is expecting a FindOneOptions<Client> but you are giving it a number instead.