Giter Club home page Giter Club logo

Comments (29)

subhoghoshX avatar subhoghoshX commented on July 29, 2024 3

I wrote an SQL query to generate the above table automatically if anyone here doesn't want to do it manually every time. Just go to the SQL Editor tab in supabase and run the query.

If you find any mistake in the query below, please let me know.

-- Create a table for Public Questions
create table questions (
  id bigint generated by default as identity primary key,
  created_at timestamp with time zone default timezone('utc'::text, now()) not null,
  created_by uuid references auth.users(id) not null,
  company text,
  location text,
  asked_date date,
  question text,
  question_details text,
  stay_anonymous boolean,
  is_approved boolean,
  position text
);

from defaang.

iShibi avatar iShibi commented on July 29, 2024 1

I can pick the work from here

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024 1

@iShibi sure! That'd be great.

from defaang.

iShibi avatar iShibi commented on July 29, 2024 1

Didn't get time to start the work, you can take it @ykdojo

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

The first step for this task: design the database schema.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

I'm going to start working on this one soon.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

Users table:

Image

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

I'm going to un-assign myself since I'll be away - in case anyone else wants to take it. I'll assign myself when I start working on it again.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

From my own comment on #59:

The required fields:

  • Company (FAANG+, or a custom textbox)
  • Position
  • Location
  • Date (how long ago was this asked?)
  • Question (100 char max?)
  • Question details
  • Stay anonymous (checkbox)

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

For the question table, this setup should be replicated:

image

created_by is a foreign key to the auth.users table.

image

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

A rough plan for this feature:

  • Assumption: a user is already logged in
  • Frontend: the user submits a question
  • It goes to an API function within Next.js / Vercel
  • We verify that the user is logged in there (pass a JWT there)
  • It then calls Supabase with admin access
  • The question is inserted in the table.

This whole process may seem a bit complicated, but I think this is the right way to do it to make it as secure as possible.

I've even thought about switching to Firebase because it's complicated, but the workflow with it would be essentially the same.

There may be other ways of going about it (e.g., using row level security / RLS), but the above approach should be the simplest one. I'll document everything as I go here.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

Documentation references:

(Extra - thinking of sending a PR to update the Supabase doc here once I'm done with this whole process)

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

I did some more research on this.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

update: verified that supabase.auth.session().access_token worked for getting the JWT.

next step: set up a Next.js API and send it there.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

note: the current user can be retrieved with supabase.auth.user()

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

I'm going to unassign myself for now to work on #122 first.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

Note: we should add a position field to the table.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

@iShibi any progress? If not, I was thinking of working on this one

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

I'll let you know if/when I start working on it

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

updated schema:

Image

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

reference: supabase insert

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

note on supabase service role: supabase/supabase#1284

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

After some more digging, I found that Supabase has a Next.js auth component - I'll look into this one next: https://github.com/supabase/auth-helpers/blob/main/packages/nextjs/README.md

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

I thought this might work, but it doesn't quite work the way it's described in the doc.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

This one worked!

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

Note: I'm currently checking this example to see how they solved it.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

I've found this comment to be helpful, too.

from defaang.

ykdojo avatar ykdojo commented on July 29, 2024

update: I'll be working off of this draft PR

from defaang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.