Scott P
07/30/2021, 3:12 PMupdate
example I use in a prod environment without a problem:
js
SupabaseClient.from(`my_table:my_column=eq.some_value`)
.on("UPDATE", (payload) => {
console.log("🔥 Received update via subscription from Supabase");
})
.subscribe(result => {
if (result !== "SUBSCRIBED") {
console.log(`❌ Error subscribing: ${result}.`);
} else {
console.log(`🔥 Opened subscription`);
}
});
Scott P
07/30/2021, 3:06 PMstibbs
07/31/2021, 1:29 AMOlyno
07/31/2021, 2:12 AMstibbs
07/31/2021, 2:34 AMKhan W
07/31/2021, 4:37 AMKhan W
07/31/2021, 4:37 AMKhan W
07/31/2021, 4:38 AMhieu
07/31/2021, 7:49 AMKhan W
07/31/2021, 8:24 AMKhan W
07/31/2021, 3:06 PMjavascript
supabase
.rpc("getEmptyStats", {
guild: guild,
startDates: startDates,
endDates: endDates,
dateCount: startDates.length,
})
.then((data, error) => {
console.log(data);
console.log(error);
});
The RPC returns an array of ints for some stats queries, however I'm having troubles calling the function and getting this error:
bash
{
error: {
hint: 'No function matches the given name and argument types. You might need to add explicit type casts.',
details: null,
code: '42883',
message: 'function public.getEmptyStats(dateCount => text, endDates => text, guild => text, startDates => text) does not exist'
},
data: null,
count: null,
status: 404,
statusText: 'Not Found',
body: null
}
Is there a way to typecast this in JS? Or do I need to do it in SQL.Khan W
07/31/2021, 3:07 PMstartDates
and endDates
variables are arrays, but look like they're being interpreted as strings when passed to the RPC function, can I pass arrays to the function? Or do I need to send a CSV string and parse it in SQL or something like thatKhan W
07/31/2021, 3:07 PMsql
FUNCTION public.getEmptyStats(guild int8, startDates timestamp[], endDates timestamp[], dateCount int)
amserra
07/31/2021, 8:58 PMuser
08/01/2021, 9:17 AMjs
useEffect(() => {
const session = supabase.auth.session();
setUser(session?.user ?? null);
const { data: authListener } = supabase.auth.onAuthStateChange(
async (event, session) => {
const currentUser = session?.user;
setUser(currentUser ?? null);
}
);
return () => {
authListener?.unsubscribe();
};
}, [user]);
so what does ??
mean in setUser(session?.user ?? null)
unrealg
08/01/2021, 9:21 AMAzura
08/01/2021, 9:21 AMsession?.user
with user
to make it simple for you.
user ?? null
,
is equivalent to:
js
if (user == null){
return null;
// Which is redundant because user is already null
// Recommended: return 'user' instead
} else {
return user;
}
The code above doesn't make much sense because it was used wrongly.
It should generally be used like this in an example:
total_likes ?? 0
,
which can be translated to:
js
if (total_likes == null){
return 0;
} else {
return total_likes;
}
unrealg
08/01/2021, 9:21 AMuser
08/01/2021, 9:23 AMuser ??
= if (user == null)
and null
after ??
is to return null if user is equal to null ?Azura
08/01/2021, 9:23 AMuser
08/01/2021, 9:24 AM??
a lotAzura
08/01/2021, 9:25 AMTrey
08/02/2021, 9:14 PMjavascript
logUserOut() {
supabase.auth.signOut();
this.$router.push("/");
},
Trey
08/02/2021, 9:14 PMjavascript
state: {
userInformation: null,
loggingIn: false,
},
mutations: {
login(state, payload) {
state.userInformation = payload;
},
attemptLogin(state) {
state.loggingIn = true;
},
finishAttemptLogin(state) {
state.loggingIn = false;
},
session(state) {
state.session = true;
},
},
So I'm guessing something like
javascript
CLEAR_STATE(state) {
state.session = false;
},
?Trey
08/02/2021, 9:15 PMSucipto
08/03/2021, 12:04 AMjs
state:{...},
mutations:{...},
actions: {
async logout({ commit }) {
const { error } = await supabase.auth.signOut();
if (!error) {
commit('clear_user') // clear user/session information
// import from router
router.replace('/')
}
}
}
Skolder
08/03/2021, 4:04 AMuser
08/03/2021, 11:17 AMuser
08/03/2021, 11:19 AMuser
08/03/2021, 11:27 AM