Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert RTDB sample to modular admin SDK #1043

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions 2nd-gen/uppercase/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ const {onValueCreated} = require("firebase-functions/v2/database");
const {logger} = require("firebase-functions");

// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require("firebase-admin");
admin.initializeApp();
const {initializeApp} = require("firebase-admin/app");
const {getDatabase} = require("firebase-admin/database");

const app = initializeApp();
const db = getDatabase(app);
// [END import]

// [START addmessage]
Expand All @@ -38,8 +41,7 @@ exports.addmessage = onRequest(async (req, resp) => {
// [START adminSdkPush]
// Push the new message into the Realtime Database
// using the Firebase Admin SDK.
const snapshot = await admin
.database()
const snapshot = await db
.ref("/messages")
.push({original: original});

Expand Down