查看完整版本 : 請問有咩好用nodejs library 可以在client side query json data

我的無比膏 2018-12-22 03:55 PM

請問有咩好用nodejs library 可以在client side query json data

得幾百條record ,根據唔同條件,想在clients side 計算max, min, avg 等等
類似SQL language

marcoCCCH 2018-12-29 02:08 PM

koa2

bickey 2019-1-1 06:55 PM

lodash
var clients = [
    {
        user: "one",
        amount: 1
    },
    {
        user: "two",
        amount: 2
    },
    {
        user: "one",
        amount: 3
    },
    {
        user: "two",
        amount: 4
    }
];

var results = [];
var result = 0;

console.log("data:", clients);

var selected = _.filter(clients, (o) => {
    return o.user === "two";
});

result = _.meanBy(selected, (o) => {
    return o.amount;
});

result = _.reduce(selected, (sum, o) => {
    return sum + o.amount;
}, 0);

result = _.maxBy(selected, (o) => {
    return o.amount;
}, 0);

result = _.minBy(selected, (o) => {
    return o.amount;
}, 0)

[[i] 本帖最後由 bickey 於 2019-1-1 07:03 PM 編輯 [/i]]
頁: [1]
查看完整版本: 請問有咩好用nodejs library 可以在client side query json data