WIP WIP test mit mongoseries
actions/getsensordata - in getActData send mongo data databases/mongo.js - fetchActData: sort by datetime and project sot all data
This commit is contained in:
@@ -137,8 +137,10 @@ export async function getSensorData(params) {
|
|||||||
// export const getActData = async (opts) => {
|
// export const getActData = async (opts) => {
|
||||||
export async function getActData(opts) {
|
export async function getActData(opts) {
|
||||||
let retI = await influx.fetchActData(opts)
|
let retI = await influx.fetchActData(opts)
|
||||||
|
retI.mongo = false
|
||||||
let retM = await mongo.fetchActData(opts)
|
let retM = await mongo.fetchActData(opts)
|
||||||
return retI
|
retM.mongo = true
|
||||||
|
return retM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -151,10 +151,11 @@ export const fetchActData = async (opts) => {
|
|||||||
start = DateTime.fromISO(start).toJSDate()
|
start = DateTime.fromISO(start).toJSDate()
|
||||||
end = DateTime.fromISO(end).toJSDate()
|
end = DateTime.fromISO(end).toJSDate()
|
||||||
let query = {sensorid: opts.sensorid, datetime: {$gte: start, $lt: end}}
|
let query = {sensorid: opts.sensorid, datetime: {$gte: start, $lt: end}}
|
||||||
|
let options = { projection: {_id: 0, values: 1, datetime: 1}, sort: {datetime: 1}}
|
||||||
let client = await connectMongo()
|
let client = await connectMongo()
|
||||||
try {
|
try {
|
||||||
ret.values = await client.db(MONGOBASE).collection('sensors')
|
ret.values = await client.db(MONGOBASE).collection('sensors')
|
||||||
.find(query).toArray()
|
.find(query, options).toArray()
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
ret.err = e
|
ret.err = e
|
||||||
|
|||||||
Reference in New Issue
Block a user