2

I am trying to create a "Users" list. But I am not able to replicate the way it is structured in the docs https://www.firebase.com/images/data_structure.png.

Instead my structure has a Users with child nodes having some raw text. https://www.evernote.com/shard/s52/sh/21c878d6-4978-440c-a089-10da4fb6d792/2d0d7a90861ef6f94e425fdb904b8ab2 Instead I want child nodes named as 'john','terry' etc as shown in your docs.

Hope this makes sense. Thanks

3
  • I'm afraid I don't understand your question. Could you give more detail? Firebase data can be structured any way you like. Commented Jan 10, 2013 at 7:36
  • I have attached the screenshot of my datastructure. Hope it explains you. Thanks @AndrewLee Commented Jan 10, 2013 at 8:34
  • Got it! Thanks for sending the screenshot. Sounds like you should be using "child" instead of "push". See Kato's answer below. Commented Jan 10, 2013 at 18:51

1 Answer 1

4

It looks like you're talking about the keys. In the Firebase example, the keys are things like fred, but in your data they appear as -iKvpJ...

If you insert your records using push, then Firebase automatically assigns the key:

firebase.child('users').push({ name: 'Fred' });

// /users/-KvpJ.../name/Fred

Use child and set to specify your own keys:

firebase.child('users/fred').set({ name: 'Fred' });

// /users/fred/name/Fred
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.