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:
rxf
2023-06-03 19:21:23 +02:00
parent edeb871c2b
commit 30bd17b130
2 changed files with 5 additions and 2 deletions
+3 -1
View File
@@ -137,8 +137,10 @@ export async function getSensorData(params) {
// export const getActData = async (opts) => {
export async function getActData(opts) {
let retI = await influx.fetchActData(opts)
retI.mongo = false
let retM = await mongo.fetchActData(opts)
return retI
retM.mongo = true
return retM
}
+2 -1
View File
@@ -151,10 +151,11 @@ export const fetchActData = async (opts) => {
start = DateTime.fromISO(start).toJSDate()
end = DateTime.fromISO(end).toJSDate()
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()
try {
ret.values = await client.db(MONGOBASE).collection('sensors')
.find(query).toArray()
.find(query, options).toArray()
}
catch(e) {
ret.err = e