Difference between revisions of "P5JS-Google-Firebase-Realtime-Database"

From Digipool-Wiki
Jump to: navigation, search
(Created page with "<pre> // Configuration of Google Reamtime Database at Firebase // Worked on January 4, 2024. // // Google Firebase Spark Plan (No-cost) // Simultaneous connections: 100 // GB...")
 
Line 1: Line 1:
 
<pre>
 
<pre>
  
// Configuration of Google Reamtime Database at Firebase
+
// Configuration of Google Realtime Database at Firebase
 
// Worked on January 4, 2024.
 
// Worked on January 4, 2024.
 
//
 
//

Revision as of 20:35, 4 January 2024


// Configuration of Google Realtime Database at Firebase
// Worked on January 4, 2024.
//
// Google Firebase Spark Plan (No-cost)
// Simultaneous connections: 100
// GB stored: 1 GB 
// GB downloaded: 10 GB/month
// One databases per project
//
/*
Include these two lines in your HTML header:
<script src="https://www.gstatic.com/firebasejs/8.0.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.0.0/firebase-database.js"></script>
*/

var firebaseConfig = {
  apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  authDomain: "xxxxxxxx.firebaseapp.com",
  databaseURL: "https://xxxxxxxxxxxxxxxxx.firebasedatabase.app",
  projectId: "xxxxxxxx",
  storageBucket: "xxxxxxxx.appspot.com",
  messagingSenderId: "xxxxxxxx",
  appId: "x:xxxxxxx:web:xxxxxxxxx",
  measurementId: "xxxxxxxxxx"
};

// Firebase initialisieren
firebase.initializeApp(firebaseConfig);

// Datenreferenz
var database = firebase.database();

// Daten, die gespeichert werden sollen
var data = {
  name: "Max Mustermann",
  email: "max.mustermann@example.com",
  age: 30,
};

// Abspeichern der Daten in Firebase
database.ref("users").push(data, function (error) {
  if (error) {
    console.log("Fehler beim Speichern der Daten: " + error);
  } else {
    console.log("Daten erfolgreich gespeichert.");
  }
});