Lukas
11/04/2022, 4:48 AMjs
"use client";
import "./globals.css";
import { createBrowserSupabaseClient } from "@supabase/auth-helpers-nextjs";
import { SessionContextProvider } from "@supabase/auth-helpers-react";
import { useState } from "react";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const [supabaseClient] = useState(() => createBrowserSupabaseClient());
return (
<html lang="en">
<head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/favicon.ico" />
</head>
<body>
<SessionContextProvider
supabaseClient={supabaseClient}
initialSession={null}
>
{children}
</SessionContextProvider>
</body>
</html>
);
}
felsey
11/04/2022, 7:09 AMlists
and a table for user_list_relations
. The user_list_relations
table is joined with the lists
table via the list_id.
The user_list_relations
table also has a column called user_profile_id
which match the auth.uid().
I need to setup RLS so that a user can read, instert, update, or delete a list if they have a user_list_relation
for that list.
I'm assuming the correct order of operations when creating a new list is:
1. Insert a new row for the list
2. Create the user_list_relation using the list_id from the list that was just created.
But, I'm not sure how this all comes together with RLS.
Let me know what additional info I can provide. Thanks!Kcrik
11/04/2022, 8:38 AMbad_advice
11/04/2022, 11:51 AMquick_piper15
11/04/2022, 12:41 PMPlayWolf
11/04/2022, 12:51 PMUser
-Model in my prisma.schema
. Though I did notice that Supabase has their own system for users, which in return allows for authentication with google, github, etc.. I do want to use this, though I am not sure on how I should implement the authentication-logic with Redwood, and how I need to adjust my prisma.schema
to reference users and their data.
For reference, here is (a part of) my prisma.schema
-file:
/// The User model
model User {
id String @id @default(cuid())
email String @unique
username String @unique
// Previously used for dbAuth, will be removed.
hashedPassword String
salt String
resetToken String?
resetTokenExpiresAt DateTime?
artist Artist?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
/// The artist profile of a user. It contains information about tags, commission packages, etc.
model Artist {
id String @id @default(cuid())
/// An artist always refers to its user
user User @relation(fields: [userId], references: [id])
userId String @unique
/// If an artist is well known, he may request a verification, which grants him a verification-badge so users can recognize him
verified Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Do I still need a User
-Model, or would I scrap that entirely? What would the Artist
-Model reference instead?
And how would I have to setup the api/functions/auth.ts
from RedwoodJS, so it would work with the users from Supabase?
Thanks in Advance!chrismatic
11/04/2022, 1:37 PMpsql -h db.jvjklainlryyksyluimc.supabase.co -p 5432 -d postgres -U postgres
psql: error: connection to server at "db.jvjklainlryyksyluimc.supabase.co" (54.147.142.241), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
The app and supbase dashboard still work and I was also able to connect from a friend's server. Next I ran a traceroute on the IP and successfully got past my home network. Could my IP have been blacklisted somehow?
Thanks in advance!gouhst
11/04/2022, 2:29 PMPlease try again. If the failures persist, please contact Supabase support with the following details:
Change tracking ID: fd0d6309-4c12-466e-9ed0-a9a2168e5930
Error message: failed to update configuration for API services
Attempt 2:
Please try again. If the failures persist, please contact Supabase support with the following details:
Change tracking ID: 4e47b563-8a03-47c3-a783-01d5b26697d7
Error message: failed to update configuration for API services
Not sure if relevant, but I was on the free tier and this project was automatically paused before I un-paused it recently. I seem to have found a few others who've reported this issue after being paused and then un-pausing, like here: https://github.com/supabase/supabase/discussions/6637#discussioncomment-2831867. I upgraded to Pro today to see if that would help (hasn't so far yet). This is also the same issue in support tickets 1194082374 and 1191832961. Any help so that I can interact with my supabase project again would be greatly appreciated!Thoth Trismegistus
11/04/2022, 2:54 PMts
import supabase from '~/lib/supabase'
import type { Database } from '~/lib/database.types'
async function getMovies() {
return await supabase.from('movies').select('id, title, actors(*)')
}
type Actors = Database['public']['Tables']['actors']['Row']
type MoviesResponse = Awaited<ReturnType<typeof getMovies>>
type MoviesResponseSuccess = MoviesResponse['data'] & {
actors: Actors[]
}
How do you use this when calling the function?brassotron
11/04/2022, 4:00 PMsupabase db reset
on the remote database to wipe it?Jingly
11/04/2022, 4:23 PMlimiteInductive
11/04/2022, 5:22 PMThoth Trismegistus
11/04/2022, 5:44 PMtrackings
with user_id
, and a profiles table with id related to users table.
I am trying to query tracking table and get the corresponding profile.Ranjeet
11/04/2022, 6:02 PMdrewbie
11/04/2022, 7:06 PMcart_items
which have a product_id
and an account_id
. the Products table also has an account_id
.
I am trying to create an RLS policy on insert so that you cannot add your own products to your cart but this doesn't seem to work. What am I missing . Appreciate the help!
create policy "Cart items cannot be added for cart account's products"
ON public.cart_items for INSERT
to authenticated
WITH CHECK (
not exists (
select 1 from products
where products.account_id = account_id
)
);
caseycrogers
11/04/2022, 7:44 PMThoth Trismegistus
11/04/2022, 8:04 PMVerify that 'trackings' and 'users' exist in the schema 'public'
doesn't relationship works with users table?Matt
11/04/2022, 9:17 PMtitle, text
content, text
tags, array of text
if I have a search request with the phase "wow so cool minecraft" it should be able to select a 'post' with these values for example
title "wow that nice"
content "this is so cool"
tags ["minecraft", "gaming"]
I was trying to use something this, it works for 'title' and 'content', but doesn't search 'tags'
let { data: posts, error } = await supabase
.from('posts')
.select(`*, profiles(*), comments(count)`)
.textSearch('title, content, tags', `'minecraft'`)
Also how I can I make it so it doesn't have to match the entire word? Like searching "test" could still match "latest"
ThanksDeed
11/04/2022, 9:21 PMuser8923
11/04/2022, 9:46 PMfelsey
11/04/2022, 9:48 PM(auth.uid() = creator_profile_id)
and this is the code to create insert a row.
const { data, error: listError } = await supabase
.from("lists")
.insert([
{
creator_profile_id: user.id,
name: listName,
google_place_id: selectedPlace.placeId,
google_place_name: selectedPlace.description,
google_place_types: JSON.stringify(selectedPlace.types),
photo_url: await getPhoto(selectedPlace?.description),
},
])
.select("*");
What's the best way to debug this and figure out why it's saying that new row violates row-level security policy for table \"lists\"
faizan98
11/04/2022, 10:45 PMjkohlin
11/04/2022, 11:32 PM@id
🙂 :
```
begin
delete from public.bets where user_id=@id; <-- This isn't working
delete from public.final_bets where user_id=$id; <-- neither is this
delete from public.profiles where id=auth.user.uid; or this for that matter
end;Cory
11/05/2022, 1:34 AM((()))
11/05/2022, 1:36 AMKhalifa007
11/05/2022, 9:19 AM{error: {code: PGRST200, details: null, hint: Verify that 'users' and 'user_id' exist in the schema 'public' and that there is a foreign key relationship between them. If a new relationship was created, try reloading the schema cache., message: Could not find a relationship between 'users' and 'user_id' in the schema cache}}
code :
import { serve } from "https://deno.land/std@0.131.0/http/server.ts"
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.0.0";
console.log("Hello from Functions!")
const SUPABASE_URL = Deno.env.get("SUPABASE_URL");
const SUPABASE_ANON_KEY = Deno.env.get("SUPABASE_ANON_KEY");
serve(async (req) => {
const { user_id } = await req.json()
const supabase = createClient(
SUPABASE_URL!,
SUPABASE_ANON_KEY!,
{
global: {
headers: { Authorization: req.headers.get("Authorization")! },
},
},
);
const { data, error } = await supabase
.from("users")
.select('*,user_id(id)')
.eq("user_id", user_id)
.limit(1)
.single();
if(error) return new Response(
JSON.stringify({error:error}),
{ headers: { "Content-Type": "application/json" } },
)
return new Response(
JSON.stringify(data),
{ headers: { "Content-Type": "application/json" } },
)
})
Solid Snake
11/05/2022, 11:17 AMabdulrahimiliasu
11/05/2022, 12:12 PMmockSupabaseClient.from.mockImplementationOnce(("profiles") => {
return new PostgrestQueryBuilder(url,{}) })
Muezz
11/05/2022, 12:23 PME/flutter ( 8376): , code: 414, details: URI Too Long, hint: null)
E/flutter ( 8376): #0 PostgrestBuilder._parseResponse
package:postgrest/src/postgrest_builder.dart:251
E/flutter ( 8376): <asynchronous suspension>
E/flutter ( 8376): #1 PostgrestBuilder.then
package:postgrest/src/postgrest_builder.dart:329
E/flutter ( 8376): <asynchronous suspension>
E/flutter ( 8376):
1) Is there a setting within Supabase which I can toggle to allow for such large insertions?
2) If not, is there a solution or a better alternative?
3) Or should I just limit the number of rows that my users will be allowed to upload? In that case, what is the max allowed number for bulk insertion?Ivan Kartashov
11/05/2022, 1:12 PMpython
from supabase import create_client, Client
supabase: Client = create_client(url, key)
#Afterwards I do the auth:
email: str = str(user_mail)
password: str = str(user_pass)
supabase.auth.sign_in(email=email, password=password)
#Then I try to INSERT a new row and recieve mentioned error:
data = supabase.table(table_name).insert({"tg_id": user_id, "name": name}).execute()
Guys, could you please help me to resolve this?