darklord
01/25/2022, 4:36 PMAhlin Chan
01/26/2022, 12:01 AMsql
select id from servers where count(select * from server_bots where servers.id = server_bots.id) < 25;
Using @supabase/supabase-js
mitul
01/26/2022, 2:25 AMjs
async function getPath() {
try {
setLoading(true)
let { data, error, status } = await supabase.storage
.from("user-library")
.list("", {
limit: 100,
})
if(error) {
throw error
}
const imageURL = data.map(item => URL.createObjectURL(item)) /* THIS LINE */
console.log(imageURL)
} catch (error) {
console.log("error", error);
}
}
mitul
01/26/2022, 2:29 AMname
of each image?mitul
01/26/2022, 3:07 AMgaryaustin
01/26/2022, 3:09 AMAhlin Chan
01/26/2022, 2:43 PMsql
select id from servers where count(select * from server_bots where servers.id = server_bots.id) < 25;
Using @supabase/supabase-js
What i want to achieve is that i want to obtain an id for a server which has less than 25 bots registered in it. To do this with SQL i can use count(...)
which will count the entries that has the same server id.
I'm aware i can retrieve the entries in server_bots
that has the same server id then i count them using if statement in JavaScript; and i repeat till i get a server id that points to a server that has less than 25 bots, but this practice seems to be bad as it will be expensive when the number of servers increase.
i want to know what is better way to do this Using @supabase/supabase-js
, thank you!.ze
01/26/2022, 6:34 PMze
01/26/2022, 6:35 PMjonny
01/27/2022, 6:34 PMa99111cc042b477e9f22eafe7
01/27/2022, 8:18 PM{
message: 'FetchError: request to https://xxx.supabase.co/rest/v1/episodes?select=id%2Cduration&offset=0&limit=1 failed, reason: connect EHOSTUNREACH xx',
details: '',
hint: '',
code: 'EHOSTUNREACH'
}
ThePhilip
01/28/2022, 3:30 AMgaryaustin
01/28/2022, 3:41 AMberu
01/28/2022, 10:25 AMauth.user()
doesn't work in the load()
function in sveltekit? it always returns null
, even though it works fine in the regular script tags. in the load function, i'm trying to query from a table with a rls policy auth.role() = 'authenticated
, but it keeps failing. changing the check with auth.role() = 'anon'
works for some reason. i'm guessing this is related to the auth.user()
returning null
.chipilov
01/28/2022, 10:41 AMAmusedGrape
01/28/2022, 2:25 PMts
supabaseServer.from<Workspace>('workspaces').on('UPDATE', (payload) => {
console.log(payload)
}).subscribe();
am I doing something wrong? thanks!garyaustin
01/28/2022, 3:54 PMPeter Hase
01/30/2022, 9:58 PMSIGNED_IN
event in supabase.auth.onAuthStateChange
anymore (SIGNED_OUT
works). Does anyone know what the cause could be?
I am using a context where I listen to the auth changes, but for some reason, after receiving the callback from the provider, the auth listener does not trigger the login event.
The auth context & _app.tsx
for reference: https://gist.github.com/PedroHase/4be266793731879210fec284ac02f4b9AmusedGrape
01/31/2022, 3:20 AMAmusedGrape
01/31/2022, 3:20 AMjs
function AuthProvider({ children }: { children: ReactNode }) {
const [user, setUser] = useState<User | null>();
const [session, setSession] = useState<Session | null>();
const [isAuthenticated, setIsAuthenticated] = useState(false);
const [loading, setLoading] = useState(false);
useEffect(() => {
setLoading(true)
const session = supabase.auth.session()
setSession(session)
setIsAuthenticated(session !== null)
const user = supabase.auth.user()
setUser(user)
setLoading(false)
supabase.auth.onAuthStateChange(async (event, session) => {
let newUser = supabase.auth.user();
setUser(newUser)
if (newUser && event === 'SIGNED_IN') {
const r = fetch(`${process.env['NEXT_PUBLIC_API_ENDPOINT']}/api/v1/supabase/set`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${session?.access_token}`
},
body: JSON.stringify({ event, session }),
})
}
})
})
return (
<AuthContext.Provider value={{
session: isAuthenticated ? supabase.auth.session() : null,
user,
loading,
login: async (redirect?: string) => {
await supabase.auth.signIn({ provider: 'discord' }, { redirectTo: redirect })
},
logout: async () => {
await supabase.auth.signOut()
},
}}>
{children}
</AuthContext.Provider>
)
}
Peter Hase
01/31/2022, 9:15 AMsilentworks
01/31/2022, 9:54 AMDNI9
02/01/2022, 7:44 PMsupabase.auth.session()
or await supabase.from('profiles').select()
on nextjs page it works as expected but when I call these on getStaticProps
, it just returns null
or
{
error: null,
data: [],
count: null,
status: 200,
statusText: 'OK',
body: []
}
If anyone faced this, or have any idea what's wrong, please share.stelofo
02/01/2022, 7:53 PMstelofo
02/01/2022, 7:54 PMgaryaustin
02/01/2022, 8:06 PMgaryaustin
02/01/2022, 8:07 PMjesucrypto
02/02/2022, 4:25 PMMorza (Chris)
02/02/2022, 5:50 PMTaner Nill
02/02/2022, 7:48 PM