I am trying to add new data fields into existing list in firebase realtime database. I am using push() to generate unique ID in one of my function. In the next function how do I map the new data under the same unique ID so that new data gets appended under the same ID. Below is the fulfillment code:
function reportHandler(agent){
const t2 = agent.parameters.name;
const t3 = agent.parameters.college;
const t4 = agent.parameters.branch;
const t5 = agent.parameters.year;
return admin.database().ref('data').push().set({
name: t2,
college: t3,
branch: t4,
year: t5
});
This code works perfectly and creates a unique ID field in the database. What I want to do next is to add new data into the previously created unique ID field.
function detailsHandler(agent){
const t1 = agent.parameters.prtype;
const t6 = agent.parameters.desc;
const t7 = agent.parameters.when;
return admin.database().ref('data').push().set({
prtype: t1,
desc: t6,
when: t7
});
This is another function which has some values. I want values from both the functions into one field with unique ID.
I am calling the functions with this
let intentMap = new Map();
intentMap.set('Report', reportHandler);
intentMap.set('Report.details', detailsHandler);
agent.handleRequest(intentMap);
New field with unique ID gets created but with values from only the first function
This is what I want(values from both the functions into one field)