_design/slow_control_time
and _design/slow_control_time_label
These views are the main views for querying data (getting data from a database). It works on documents that looks like:
{
"type" : "data",
// ..
"value" : {
"data_1" : 1.23 // a number value
// ..
}
}
and emits for each data point (all keys in "value"
).
slow_control_time
This view emits as key: [data_name, Y, M, D, H, M, S]
.
map
function(doc) {
if (!doc.type || doc.type != 'data') return;
var then = new Date(Date.parse(doc.timestamp));
for (var key in doc.value) {
emit([key,
then.getUTCFullYear(), then.getUTCMonth(),
then.getUTCDate(), then.getUTCHours(),
then.getUTCMinutes(), then.getUTCSeconds()], Number(doc.value[key]));
}
}
reduce
: _stats
slow_control_time_label
This view simply reverses the ordering of the output key, so: [Y, M, D, H, M, S, data_name]
.
map
function(doc) {
if (!doc.type || doc.type != 'data') return;
var then = new Date(Date.parse(doc.timestamp));
for (var key in doc.value) {
emit([
then.getUTCFullYear(), then.getUTCMonth(),
then.getUTCDate(), then.getUTCHours(),
then.getUTCMinutes(), then.getUTCSeconds(), key], doc.value[key]);
}
}
reduce
_stats
pynedm
: