我从firebase开始,我创建了一个包含对象的实时数据库。我想从firebase中使用nodejs函数检索该对象并将其显示在控制台中。到目前为止,我已经使用nodejs创建了firebase项目,但是我不确定如何从实时数据库中检索数据。
index.js文件
const functions = require('firebase-functions');
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });
const admin = require('firebase-admin');
let serviceAccount = require('xxxxxxxxxxxxxxxxxxxx.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
firebase中的实时数据库
{
"UpcomingClasses" : {
"course" : "chemistry",
"date" : "27-8-1996",
"enrolled" : "string",
"instructor" : "string",
"location" : "string"
}
}