Reputation: 570
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.
Upvotes: 1
Views: 486
Reputation: 570
By now I actually moved from MongoDB to InfluxDB thanks to the perfect handling of timeseries-data.
Upvotes: 1