领域Javascript是否支持Join,Group By和Aggregation功能

时间:2017-05-03 02:44:24

标签: react-native realm realm-mobile-platform

要开发一个显示统计数据的React Native移动应用程序,以及广泛使用的函数,Realm是否能满足需求?

加入
分组由 聚集
自动递增

请建议任何其他最适合统计应用的ORM / DB?

1 个答案:

答案 0 :(得分:0)

替代方案

您可以在 Realm Database 中获取日期,然后通过 useign js group by

// Accepts the array and key
const groupBy = (array, key) => {
  // Return the end result
  return array.reduce((result, currentValue) => {
    // If an array already present for key, push it to the array. Else create an array and push the object
    (result[currentValue[key]] = result[currentValue[key]] || []).push(
      currentValue
    );
    // Return the current iteration `result` value, this will be taken as next iteration `result` value and accumulate
    return result;
  }, {}); // empty object is the initial value for result object
};

// Group by color as key to the person array
const personGroupedByColor = groupBy(person, 'color');