Mongo-Zugriff passt jetzt

Adresse wird richtig geholt
Daten werden in prop_flux gespeichert
This commit is contained in:
2025-08-18 13:35:59 +00:00
parent 81c92dcd5c
commit 61f8dec32f
3 changed files with 76 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
import { ObjectId } from 'mongodb';
import { MongoAPIError, ObjectId } from 'mongodb';
import bcrypt from 'bcrypt';
import { getCollections } from '../db/mongo.js';
import { getCollections, update_pflux } from '../db/mongo.js';
export function registerApiRoutes(app, requireLogin) {
const { entriesCollection, usersCollection } = getCollections();
@@ -25,14 +25,12 @@ export function registerApiRoutes(app, requireLogin) {
sensorNumber = parseInt(sensorNumber, 10);
try {
const doc = {
espId,
sensorNumber,
id: espId,
name: name || '',
description: description || '',
address: address || '',
createdAt: new Date()
};
await entriesCollection.insertOne(doc);
await update_pflux(sensorNumber, doc)
res.json({ success: true });
} catch (err) {
console.error(err);