Using mongodb by typeorm with nestjs - create crud rest api
When trying to get data by findone() with 'id' . getting below error
TS2345: Argument of type '{ id: string; }' is not assignable to parameter of type 'FindOneOptions'.
Object literal may only specify known properties, and 'id' does not exist in type 'FindOneOptions'.
Code:
const result = await this.sellerRepository.findOne({ id });
Entity
@Entity('seller')
export class Seller {
@ObjectIdColumn()
id: ObjectID;
@Column({
type: 'string',
nullable: false,
name: 'product_name',
})
productName: string;
@Column({
name: 'short_desc',
})
}
async findOne(id: string): Promise<Seller> {
const result = await this.sellerRepository.findOne({ id });
return result;
}