Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

How can I retrieve a list of users ? #10

Open
ghost opened this issue Mar 25, 2018 · 0 comments
Open

How can I retrieve a list of users ? #10

ghost opened this issue Mar 25, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Mar 25, 2018

Hey ! I'm struggling a bit about fetching things from my database, could yo explain to me how one can retrieve a list of users ?

I am currentrly doing this :

BsFirebase.ReasonFirebase.Database.Reference.once(
      BsFirebase.ReasonFirebase.Database.ref(db, ~path="users", ()),
      ~eventType="value",
      ()
    )
    |> Js.Promise.then_(
      (rawData) => BsFirebase.ReasonFirebase.Database.DataSnapshot.val_(rawData)
        |> (users) => { Js.log(users); users;}
        |> Js.Promise.resolve
    );

But when I take a look at what's written in the console I see an Object when I thought I would get an array. The object is formatted as the following :

{
	"user_A_key" : {
		"email":"user@A.fr",
		"role":"user@A.fr"
	},
	"user_B_key" : {
		"email":"user@B.fr",
		"role":"user@B.fr"
	},
	...

}

I thought I could iterate through the object using the "foreach" in Bs-firebase but it doesn't seem to work.

I am really new to reasonreact so everything is a little blurred for me and I'm stuck with this since 2 whole days, and because it is for a school project I don't have a lot of time left to figure it out. It may be something really easy but I can't find a way.

Thank you for helping !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants