0

I want to store unique user ids provided by Firebase, in my database.

Here is my code:

var uid = result.uid;
console.log(uid);
// Prints the unique user id


// Create User structure in FB
firebase.setValue(
  'Users',
  {uid: true}
);

This creates the following in FB:

Users
  uid: true

uid is simply that, just a string that says uid. Am I doing something incorrect?

(docs for reference)

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
skwny
  • 2,930
  • 4
  • 25
  • 45

1 Answers1

1

You'll need to use [] accessor to use the value of the uid as a key/property name:

var obj = {};
obj[uid] = true;
firebase.setValue('Users', obj);
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807