简体   繁体   English

为什么Knex.js以数组形式返回max('value')?

[英]Why does Knex.js return max('value') as an array?

I want to find max value from a table: 我想从表中找到最大值:

knexClient
    .queryBuilder()

    .withSchema('myschema')
    .from('mytable')
    .where({some_query})
    .max('value');

It returns the needed value as an array with a single element: [{max: 1000}] 它以单个元素的数组形式返回所需的值:[{max:1000}]

Why does it return an array, not just a number, or an object? 为什么它返回一个数组,而不仅仅是一个数字或一个对象?

knexClient
    .queryBuilder()

    .withSchema('myschema')
    .from('mytable')
    .where({some_query})
    .max('value')
    .first(); // Add this to get an object

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM