MongoDB-Konnektor
Übersicht
Abschnitt betitelt „Übersicht“Der MongoDB-Konnektor schreibt JSON-Dokumente in MongoDB-Sammlungen.
Konnektor-Typ: MongoWriter
Konfiguration
Abschnitt betitelt „Konfiguration“{ "type": "MongoWriter", "config": { "endpoint": "mongodb://root:password@localhost:27017/", "database": "sensor_db", "collection": "measurements" }}Konfigurationsparameter
Abschnitt betitelt „Konfigurationsparameter“- endpoint: MongoDB-Verbindungszeichenfolge
- database: Datenbankname
- collection: Sammlungsname
Verbindungszeichenfolgen-Formate
Abschnitt betitelt „Verbindungszeichenfolgen-Formate“Lokales MongoDB
Abschnitt betitelt „Lokales MongoDB“mongodb://localhost:27017/Mit Authentifizierung
Abschnitt betitelt „Mit Authentifizierung“mongodb://username:password@localhost:27017/MongoDB Atlas
Abschnitt betitelt „MongoDB Atlas“mongodb+srv://username:password@cluster.mongodb.net/Mit Optionen
Abschnitt betitelt „Mit Optionen“mongodb://localhost:27017/?authSource=admin&retryWrites=trueDatenspeicherung
Abschnitt betitelt „Datenspeicherung“Eingabe-Payload:
{ "temperature": 25.5, "humidity": 60, "timestamp": 1234567890}Als MongoDB-Dokument gespeichert:
{ "_id": ObjectId("..."), "temperature": 25.5, "humidity": 60, "timestamp": 1234567890}Anwendungsfall: IoT-Datenspeicherung
Abschnitt betitelt „Anwendungsfall: IoT-Datenspeicherung“{ "type": "MongoWriter", "config": { "endpoint": "mongodb://mongo.local:27017/", "database": "iot_platform", "collection": "sensor_readings" }}Best Practices
Abschnitt betitelt „Best Practices“- Aussagekräftige Datenbank- und Sammlungsnamen verwenden
- Timestamps zu Dokumenten hinzufügen
- Indizes für häufig abgefragte Felder verwenden
- Sammlungsgröße überwachen und Archivierung implementieren