Package.json updated

getporpertie leist nun auch die Chipdaten aus prop_flux
This commit is contained in:
2025-09-15 16:11:13 +00:00
parent 41ef7a06b2
commit 75ccb0b8ea
7 changed files with 4944 additions and 1830 deletions
+19 -4
View File
@@ -28,9 +28,9 @@ export const properties_collection = 'properties'
export const connectMongo = async () => {
try {
// logit(`Try to connect to ${MONGO_URL}`)
logit(`Try to connect to ${MONGO_URL}`)
let client = await MongoClient.connect(MONGO_URL)
// logit(`Mongodbase connected to ${MONGO_URL}`)
logit(`Mongodbase connected to ${MONGO_URL}`)
return client
}
catch(error){
@@ -52,10 +52,10 @@ const listDatabases = async (client) => {
// Read properties from the database
export const readProperties = async (query, limit = 0) => {
let ret = {err: null, properties: null}
let client = await connectMongo()
let client = await connectMongo()
try {
if ("sid" in query) { // if sid is given, read property for sid
ret.properties = await client.db(MONGOBASE).collection(properties_collection).findOne({_id: query.sid})
ret.properties = await client.db(MONGOBASE).collection('properties_collection').findOne({_id: query.sid})
} else { // otherwise read props corresponding to query
ret.properties = await client.db(MONGOBASE).collection(properties_collection).find(query).limit(limit).toArray()
}
@@ -68,6 +68,21 @@ export const readProperties = async (query, limit = 0) => {
return ret
}
export const readChipData = async (sid) => {
let ret = { err: null, chipdata: null}
let client = await connectMongo()
try {
ret.chipdata = await client.db(MONGOBASE).collection('prop_flux').findOne({_id: sid},{projection: {chip: 1, _id: 0}})
} catch (e) {
ret.err = e
}
finally {
client.close()
}
return ret
}
// read mapdata from database
export const readMapdata = async (query, limit) => {
let ret = {err: null, mapdata: []}