save rating to database

So I'm building a store in appian and i want the user to be able to rate a product and I want it saved so then ofter i can show an average rating of the product, what should I do in order to save the rating of the user in the database after i click the star icon or after i click a button to save the rating? i already have a database set up. Or if thats not possible is there any other way to do it?

  Discussion posts and replies are publicly visible

Parents
  •  a!sideBySideItem(
                item: a!richTextDisplayField(
                  label: "Rate the Product",
                  labelPosition: "ABOVE",
                  value: {
                    a!forEach(
                      items: enumerate(local!totalStars) + 1,
                      expression: {
                        a!richTextIcon(
                          icon: if(
                            fv!index <= local!rating,
                            "star",
                            "star-o"
                          ),
                          color: "ACCENT",
                          linkstyle: "STANDALONE",
                          link: a!dynamicLink(
                            value: if(local!rating=fv!index, 0, fv!index),
                            saveInto: local!rating
                          )

    I have this between the rest of the expressian

Reply
  •  a!sideBySideItem(
                item: a!richTextDisplayField(
                  label: "Rate the Product",
                  labelPosition: "ABOVE",
                  value: {
                    a!forEach(
                      items: enumerate(local!totalStars) + 1,
                      expression: {
                        a!richTextIcon(
                          icon: if(
                            fv!index <= local!rating,
                            "star",
                            "star-o"
                          ),
                          color: "ACCENT",
                          linkstyle: "STANDALONE",
                          link: a!dynamicLink(
                            value: if(local!rating=fv!index, 0, fv!index),
                            saveInto: local!rating
                          )

    I have this between the rest of the expressian

Children
No Data