PricingBlog

Database without authorization

  • benajaephrath-1276155679530422323

    BenajaEphrath

    1 year ago

    I would like to program a completely useless ToodleApp that can do the following: 10 questions with 3 different answers each. Each answer has different points: Yes = 3 points, No = 0 points and Partly = 1 point.

    At the end a result with a total score should be displayed.

    I have now created two tables in Supabase: A questions table and an answers table. The questions are very simple, and the answers are simply given the corresponding scores. BUT: I do not get the API data as long as I do not authorize myself - correct? But I don't want to create a login area, I want it to be public. Should I choose a different database?
    1276155679907905607-image.png
  • tomthebigtree-1276164898098905089

    Tom Ireland

    1 year ago

    I think this might have something to do with RLS policies in Supabase. If you want to be able to provide read access to the database to request data without authentication, you will probably need to set the policy so that the anon role can perform the read instead of authenticated iirc. That should then just allow you to read the database without being an authenticated user. You can also disable the policy iirc but not usually recommended.
  • benajaephrath-1276176406929473610

    BenajaEphrath

    1 year ago

    that's what I thought. thank you. And it makes perfect sense... well I will create a secure login area...
    🙌1
  • benajaephrath-1276449670033313852

    BenajaEphrath

    1 year ago

    I am lost. I've actually worked through all the tutorials on how to learn Toddle, but somehow my brain is stuck. I would like to achieve the following: Each answer has different points. So I have to add up the points over a formula, depending on which choice I make. But how do I add several variables to the formula, as I can only select one at a time?
    1276449669849022546-image.png
  • plusmin-1276451543993815040

    Armand

    1 year ago

    You add the score to each variable and then the score is a sum of all variables. So the sum score could be: 1 + 3 + 0 + 1 + 0 + 0
    👆1
  • And make sure to add the variables in an array
  • ❤️1
  • benajaephrath-1276465766606176361

    BenajaEphrath

    1 year ago

    Thanks so much. So this is what i have. So i assume, that i have to insert an if condition? If the Button is clicked, then sum?
    1276465766178361354-image.png
  • plusmin-1276466532183969864

    Armand

    1 year ago

    This formula will run whenever it is used. So if you want to send the score to Supabase then you just put this formula in the body and make it part of the object that creates/updates a row in your table.
  • lucasg-1276546266545000559

    Lucas G

    1 year ago

    I recommend you don't do it this way and instead, simply add all the answers to a single variable as an array
    👍1
  • benajaephrath-1277176177684906094

    BenajaEphrath

    1 year ago

    Uff I'm really stuck here. Example= Checkbox activated = then the points are added, if it is not activated, then not. The example above works well with a number-input field, but if I want to give a checkbox a value via a variable, I can't get any further. Can you show me an example where this has been implemented in this or a similar way?
  • benajaephrath-1277177165795823720

    BenajaEphrath

    1 year ago

    This is what I did: I created variables and stored the corresponding values:
    1277177165687033888-image.png
  • Bind input-checkbox to the variable:
    1277177357295423491-image.png
  • benajaephrath-1277178776316543029

    BenajaEphrath

    1 year ago

    I understand that I need a formula to calculate the score now and for that I need an array. if I take the following example, then of course it immediately adds up the value I have stored in the variables. but I want the value to be added up only when I have activated a checkbox.

    Oh man, I'm really sorry for these noob questions, but I'm kind of stuck. Once the logic is clear, then I can move on 😒
    1277178776140251189-image.png
  • lucasg-1277267043544076351

    Lucas G

    1 year ago

    I didn’t go the checkbox route
  • lucasg-1277267371026939974

    Lucas G

    1 year ago

    But essentially, I set an answer to an array with the same index as the question so that if a person went back a question their answer would be highlighted and they could choose a new one if needed
  • lucasg-1277267891238207488

    Lucas G

    1 year ago

    I advice against set variables like that if you want it to be reusable
  • sanedealer-1277306016853135361

    Edwin Paul

    1 year ago

    Something like this?
  • @BenajaEphrath
  • benajaephrath-1277501493662060576

    BenajaEphrath

    1 year ago

    YES 😍 How did you do that?
  • sanedealer-1277503860923043873

    Edwin Paul

    1 year ago

    😍1
  • benajaephrath-1277507693896269866

    BenajaEphrath

    1 year ago

    Very interesting. Thanks so much...

    My idea was as follows: