2

I have a list of acceptable jobs that a user request (user 1) from their interface and those acceptable jobs are shown to user 2 who can accept those jobs or none at all. Now I have it saving under the specific city from the request, however, within the city node I want it to save under their user ID when they hit the accept button. Therefore, within their UID, the contents of the job will list all its details.

I can't seem to get it working fully.

My JS snippet:

var ref = firebase.database().ref('requests'); var ref2 = firebase.database().ref('Providers').child("City").child("Cincinnati"); ref.on('value', function(snapshot) { ref2.set(snapshot.val(), function(error) { }); }); 

So we're showing the provider the initial request with limited info (which has a ton of info). Once they click 'accept', they're able to view all the info but I'm currently just copying that info into another snapshot.

My question:

How can I save the info under their signed in, user ID (UID)?

The tree is set up like so:

Providers City Cincinnati UID Job Key ID Job Details 
2

1 Answer 1

3

To save data under userid, get the userid first:

var user = firebase.auth().currentUser; var uid=user.uid; 

then save the data under the uid:

var ref2 = firebase.database().ref('Providers').child("City").child("Cincinnati"); ref2.child(uid).set({ jobDetails:details }); 

more info here:

https://firebase.google.com/docs/database/web/read-and-write

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.