Still looking for Database to Database help

Hi All, I am new to all this so bear with me. I have two databases one that collects my dog information and another that collects my field trial report results. My field results are collected in a drop down from my Dog Information database. So what I want to do is have my field trail report to add points to the dogs database in the order they placed on each field based on the total points each trial is worth. So dog A took first on a 3 point trial so I want the 3 points to report back to Dog A (Points column) in the database. Then dog A took second place on a 3 point trial so I want the 2 points to return back to the Dog A (Points column) for a total of 5 points.

Hello James,

You can use hooks to update the dog info collection each time a new record is added to the field results collection. For example, using afterUpdate .
Simply add a hook to the field results collection, select afterUpdate, and use the item and wixData update to update the relevant record in the dog info collection.

See more information here and here

Thanks,
still little lost but at less im in the right directions

Hi Ido,

I have a similar scenario and am trying to add the afterUpdate hook, but I don’t know where to reference the second collection. So if the code is:

export function Collection1_afterUpdate(item, context) {

Would it be added to the item or context parts?

And, like James’s question, I would like to sum the amounts from Collection 1 into a single line in Collection 2, updating whatever total is previously there. How would I do that?

Thanks!