Omitting unwanted keys or data when adding to subcollection

Hi guys! So I'm making a admin panel where there's a section where you can track an employee's leave (unpaid leave, unpaid_leave_date, paid_leave, paid_leave_date, remarks) , and whenever I make a change on the main section, which is the employee information which consists columns of age, position, date_hired, unpaid_leave_date, paid_leave, paid_leave_date, remarkss only the necessary data of the employee's leave will be added into the sub-collection(leave_history) such as unpaid leave, unpaid_leave_date, paid_leave, paid_leave_date, remarks only without the name, age, position and date_hired

I'm currently using the Firestore API as my datasource

Hey @Nur_Azril_Onkassim!

It sounds like lodash's _.pick or _.omit function might be particularly useful here - both come built-in. You could, for instance, map over your table's recordUpdates property with something like {{ table.recordUpdates.map(row => _.pick(row, ["leave", "unpaid_leave_date", "paid_leave", "paid_leave_date", "remarks"])) }}.

Curious to see a screenshot of how you currently have your update query configured though :thinking:

Hi! sorry for the very late reply, So what I've done is I made two tables with the same query but I just hid the necessary columns for a specific table as shown in the image


and for table 2 I added a insert document query where every changes that I made on table 2 would have two events which is first the the specific document would be updated on the main collection and the second event would be that it would add the changes as a new document to the sub collection of that specific document which is their leave history


Thanks for the screenshots :slightly_smiling_face:

It looks to me like _.pick would be good here.

I'm curious about how the addLeaveHistory query is working. It's triggered on save changes but references table2.selectedRow which I imagine the user might change before hitting "Save changes", the reference to i is also ambiguous when triggered from the "Save changes" handler.

It might be a good idea to either trigger the query from a button on the row or otherwise use a loop similar to what you have in updateLeaveTracker to map over all the records you'd like to add.

What do you think?