Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 views
in Technique[技术] by (71.8m points)

android - Creating Nested Object Firebase structure

I'm using Firebase as my database for my Android project. In this project, I have users with minimal data associated with them.

    users{
      1234-567-897:{
          Display:"Name",
          Email:"[email protected]"
      },
    ...

I made this structure with a basic object User with two local string variables.

My issue is that I now need to add a schedule to each user, which consists of a list of Events, each event with it's own information(Start time, End time, etc.)

I understand that my structure would probably look something like this:

users{
  1234-567-897:{
      Display:"Name",
      Email:"[email protected]",
      Schedule:{
          event1:{
               name:"Meeting",
               startTime:1,
               endTime:2
          },
          event2:{...}
      },
      Sschedule2:{...}
  },

But I have no idea how to go about creating this type of structure with Firebase. I was initially going to use an ArrayList to hold the objects of Schedules and Events but after reading the Firebase documentation, it looks like they don't support ArrayList storing. An alternative to this that I was considering was to create a separate table of schedules and reference them with uids.

Appreciate any advise regarding creating this structure, thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...