https://supabase.com/ logo
Join Discord
Powered by
# help
  • f

    frubalu

    07/27/2021, 5:34 PM
    to simplify things, would you consider changing the name of that table to just
    games
    ?
  • f

    frubalu

    07/27/2021, 5:34 PM
    normally tables are pluralized
  • f

    Flyken

    07/27/2021, 5:34 PM
    its already in my code as game_directory
  • f

    frubalu

    07/27/2021, 5:34 PM
    got it
  • f

    Flyken

    07/27/2021, 5:34 PM
    it makes sense in my head
  • f

    frubalu

    07/27/2021, 5:35 PM
    reason i say that, is because you'll probably have to specify the name of the column
    game_id
    in some calls, which could get annoying
  • f

    frubalu

    07/27/2021, 5:35 PM
    i suppose you could change that column to
    game_directory_id
  • f

    Flyken

    07/27/2021, 5:38 PM
    i renamed it
  • f

    Flyken

    07/27/2021, 5:38 PM
    so its now
    games
  • f

    Flyken

    07/27/2021, 5:38 PM
    now what?
  • f

    frubalu

    07/27/2021, 5:38 PM
    i'm assuming you're still seeing undefined for your result?
  • f

    Flyken

    07/27/2021, 5:39 PM
    yes
  • f

    Flyken

    07/27/2021, 5:39 PM
    should my query still be
  • f

    Flyken

    07/27/2021, 5:39 PM
    Copy code
    js
    let { data, error } = await supabase.from('users_games').select().eq('id', user.id);
    ?
  • f

    frubalu

    07/27/2021, 5:40 PM
    Copy code
    const fetchGames = async () => {
        if (!user) return;
    
        const { data, error } = await supabase
          .from('users_games')
          .select()
          .eq('user_id', user.id);
    
        if (error) return error;
        if (data) return data;
      };
    
      useEffect(() => {
        (async () => {
          const res = await fetchGames();
          console.log({ res });
        })();
      }, []);
  • f

    frubalu

    07/27/2021, 5:40 PM
    ^ i was thinking that might be a better way of handling that piece of code
  • f

    frubalu

    07/27/2021, 5:41 PM
    if you console log data and error inside of the
    fetchGames()
    function, what do you get?
  • f

    Flyken

    07/27/2021, 5:42 PM
    wtf
  • f

    frubalu

    07/27/2021, 5:43 PM
    Copy code
    const fetchGames = async () => {
        if (!user) return;
    
        return await supabase.from('users_games').select().eq('user_id', user.id);
      };
  • f

    frubalu

    07/27/2021, 5:43 PM
    try it more like that, just directly return the result
  • f

    frubalu

    07/27/2021, 5:43 PM
    what did you see when you console logged those two values, btw?
  • f

    Flyken

    07/27/2021, 5:43 PM
    ;_;
  • f

    Flyken

    07/27/2021, 5:43 PM
    nothing
  • f

    Flyken

    07/27/2021, 5:43 PM
    it didn't print anything
  • f

    frubalu

    07/27/2021, 5:43 PM
    oh it's not at all huh?
  • f

    frubalu

    07/27/2021, 5:43 PM
    mmk one sec, lemme think about this
  • s

    Scott P

    07/27/2021, 5:44 PM
    log out your
    user.id
    and see if it matches the one that's in that row in the table
  • s

    Scott P

    07/27/2021, 5:44 PM
    It should do, but just better to be sure
  • f

    frubalu

    07/27/2021, 5:44 PM
    ^ good call
  • f

    Flyken

    07/27/2021, 5:44 PM
    yes it matches
12345...316Latest