TypeORM:FieldResolver返回类型err:您需要为

时间:2019-12-28 10:08:01

标签: typescript typeorm

@Resolver(() => Store)
export class StoreResolver {
@FieldResolver()
    async totalFastDelivery(@Root() store: Store): Promise<number> {
        return await getRepository(Order)
            .createQueryBuilder("orders")
            .where("orders.storeId = :id", { id: store.id })
            .andWhere("orders.fastDelivery = true ")
            .getCount();
    }
}

尽管getCount()的返回类型为Promise<number>  得到这个
Error: You need to provide explicit type for StoreResolver#totalFastDelivery ! 那么,这怎么了?我应该使用其他任何类型吗?

1 个答案:

答案 0 :(得分:0)

@FieldResolver(() => Int) 会解决的。