我正尝试首次使用MongoDB收集来保存我的物联网传感器数据。 通过编写一个API,我想从MongoDB中提取数据,以便在图表中将这些数据表示给用户。
我的模式如下所示,时间戳是Linux时间戳并读取条目的浮点值。
var ReadingSchema = mongoose.Schema({ uuid: String, location: String, type: String, reading: Number, unit: String, timestamp: Number, battery: Number });读数经常保存,没有特定的时间间隔。 传感器A可以每10秒发送一次,而传感器B可以每5分钟发送一次。
我希望能够提取数据来绘制图表。 我试图按以下示例所述的时间间隔进行分组: http : //www.nrg-media.de/2013/10/mongodb-aggregation-group-by-any-time-interval/
但我得到的结果是InternalError: too much recursion或The $subtract accumulator is a unary operator 。
我也发现这个解决方案,它符合我的要求: https : //stackoverflow.com/a/27751029/1765404 。 但结果是InternalError: too much recursion 。
阅读架构可能会改变,如果这将有所帮助。 该集合现在包含过去一个月〜70,000行的虚拟数据。
I am trying to use a MongoDB-collection for the first time to save my Internet of Things sensor data. By writing an API, I would like to extract data from MongoDB to represent these to the user in a chart.
My schema is as follows, with timestamp being a Linux timestamp and reading a float value of the entry.
var ReadingSchema = mongoose.Schema({ uuid: String, location: String, type: String, reading: Number, unit: String, timestamp: Number, battery: Number });Readings are saved frequently without specific intervals. Sensor A may send them every 10 seconds, while sensor B may send them every 5 minutes.
I would like to be able to extract data to plot a chart. I tried to group the intervals described by the following example: http://www.nrg-media.de/2013/10/mongodb-aggregation-group-by-any-time-interval/
But the results I am getting are InternalError: too much recursion or The $subtract accumulator is a unary operator.
I also found this solution, which matches my requirements: https://stackoverflow.com/a/27751029/1765404. But the result is InternalError: too much recursion as well.
The reading schema may be changed if that would be helpful. The collection now consists ~70.000 rows of dummy data from the past month.
最满意答案
由于时间序列数据的完美处理,现在我实际上已经从MongoDB转移到了InfluxDB 。
By now I actually moved from MongoDB to InfluxDB thanks to the perfect handling of timeseries-data.
更多推荐
发布评论