Home > Mobile >  Attempting to set a custom key and value in a Realtime Database
Attempting to set a custom key and value in a Realtime Database

Time:03-02

I'm attempting to do the following in Firebase Real Time Database. Set a key and value:

/authUsers/
{uidSetByMe: 'Custom value"}

The code I'm attempting it with is:

var admin = require("firebase-admin");
admin.database().ref(`/authUsers`).update({ [userRecord.uid]: userData.uid })

The above gives no error it just doesn't work. I also tried: push

admin.database().ref(`/authUsers`).push({ [userRecord.uid]: userData.uid })

How can I achieve this?

CodePudding user response:

You can pass the value you want to a child call:

admin.database().ref('authUsers').child(userRecord.uid).set(userData.uid);
  • Related