Suggestions on structuring Firebase JSON tree
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
I'm in the process of creating a simple registration system for my school district using Firebase as the database. I need two things for the client: the list of available courses and the courses a user has registered for.
Following the Firebase documentation, I'm trying to keep my tree as flat as possible (full example below). I've set up an index of courses and a user index. I write registrations to both at the same time.
courses: // index all the courses available
key1:
title: "Course 1",
desc: "This is a description string.",
date: 2018-01-01 12:00:00Z
members:
user1: true
...
,
key2 ... ,
,
users: // track individual user registrations
user1:
key1: true,
...
,
user2: ...
I'm having a hard time getting the client to display user registrations because I'm trying to reference the courses
index via key
. I'm thinking my JSON structure needs to change, but I'm not entirely sure how to do that without too much nesting or repetition (and it's possible I'm overthinking this).
Would it make more sense to do something like this in the users
index rather than trying to reference back and forth?
users: // track individual user registrations with full details
user1:
key1:
title: "Course 1",
date: "2018-01-01 12:00:00Z"
,
key2: ...
,
user2: ...
javascript json firebase
add a comment |Â
up vote
0
down vote
favorite
I'm in the process of creating a simple registration system for my school district using Firebase as the database. I need two things for the client: the list of available courses and the courses a user has registered for.
Following the Firebase documentation, I'm trying to keep my tree as flat as possible (full example below). I've set up an index of courses and a user index. I write registrations to both at the same time.
courses: // index all the courses available
key1:
title: "Course 1",
desc: "This is a description string.",
date: 2018-01-01 12:00:00Z
members:
user1: true
...
,
key2 ... ,
,
users: // track individual user registrations
user1:
key1: true,
...
,
user2: ...
I'm having a hard time getting the client to display user registrations because I'm trying to reference the courses
index via key
. I'm thinking my JSON structure needs to change, but I'm not entirely sure how to do that without too much nesting or repetition (and it's possible I'm overthinking this).
Would it make more sense to do something like this in the users
index rather than trying to reference back and forth?
users: // track individual user registrations with full details
user1:
key1:
title: "Course 1",
date: "2018-01-01 12:00:00Z"
,
key2: ...
,
user2: ...
javascript json firebase
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm in the process of creating a simple registration system for my school district using Firebase as the database. I need two things for the client: the list of available courses and the courses a user has registered for.
Following the Firebase documentation, I'm trying to keep my tree as flat as possible (full example below). I've set up an index of courses and a user index. I write registrations to both at the same time.
courses: // index all the courses available
key1:
title: "Course 1",
desc: "This is a description string.",
date: 2018-01-01 12:00:00Z
members:
user1: true
...
,
key2 ... ,
,
users: // track individual user registrations
user1:
key1: true,
...
,
user2: ...
I'm having a hard time getting the client to display user registrations because I'm trying to reference the courses
index via key
. I'm thinking my JSON structure needs to change, but I'm not entirely sure how to do that without too much nesting or repetition (and it's possible I'm overthinking this).
Would it make more sense to do something like this in the users
index rather than trying to reference back and forth?
users: // track individual user registrations with full details
user1:
key1:
title: "Course 1",
date: "2018-01-01 12:00:00Z"
,
key2: ...
,
user2: ...
javascript json firebase
I'm in the process of creating a simple registration system for my school district using Firebase as the database. I need two things for the client: the list of available courses and the courses a user has registered for.
Following the Firebase documentation, I'm trying to keep my tree as flat as possible (full example below). I've set up an index of courses and a user index. I write registrations to both at the same time.
courses: // index all the courses available
key1:
title: "Course 1",
desc: "This is a description string.",
date: 2018-01-01 12:00:00Z
members:
user1: true
...
,
key2 ... ,
,
users: // track individual user registrations
user1:
key1: true,
...
,
user2: ...
I'm having a hard time getting the client to display user registrations because I'm trying to reference the courses
index via key
. I'm thinking my JSON structure needs to change, but I'm not entirely sure how to do that without too much nesting or repetition (and it's possible I'm overthinking this).
Would it make more sense to do something like this in the users
index rather than trying to reference back and forth?
users: // track individual user registrations with full details
user1:
key1:
title: "Course 1",
date: "2018-01-01 12:00:00Z"
,
key2: ...
,
user2: ...
javascript json firebase
asked Jan 25 at 15:15
Brian
1064
1064
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f185976%2fsuggestions-on-structuring-firebase-json-tree%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password