Javascript 带有Knex.js的数据加载器

Javascript 带有Knex.js的数据加载器,javascript,node.js,typescript,knex.js,Javascript,Node.js,Typescript,Knex.js,在我更新到dataloader:2.0.0之前,这段代码运行良好 现在它给出了错误: loader.ts:7:14 - error TS2769: No overload matches this call. The last overload gave the following error. Argument of type '"id"' is not assignable to parameter of type 'string[]'. 7 .wh

在我更新到dataloader:2.0.0之前,这段代码运行良好

现在它给出了错误:

loader.ts:7:14 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '"id"' is not assignable to parameter of type 'string[]'.

7     .whereIn('id', keys)
               ~~~~

  node_modules/knex/types/index.d.ts:1137:5
    1137     <TRecordInner, TResultInner>(
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1138       columnNames: string[],
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1139       values: QueryBuilder<TRecordInner, TResultInner>
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1140     ): QueryBuilder<TRecord, TResult>;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The last overload is declared here.


Found 1 error.

Stack:Apollo server express、TypeScript、Postgres、Knex.js

Knex TypeScript似乎希望您将字符串数组string[]设置为其中的第一个参数,如下所示:

const products: Product[] = await knex('product')
  .whereIn(['id'], keys)
  .select();
这与在多个列中搜索时相同。以下示例来自Knex.js文档:

knex.select('name').from('users')   
  .whereIn(['account_id', 'email'], [[3, 'test3@example.com'], [4, 'test4@example.com']])
希望有帮助, 致意

knex.select('name').from('users')   
  .whereIn(['account_id', 'email'], [[3, 'test3@example.com'], [4, 'test4@example.com']])