Khan 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.Scott P
07/31/2021, 3:14 PMguild: Number(guild)
which might fix itScott P
07/31/2021, 3:15 PMstartDates => text
though, since .length
should always return a number in JSKhan W
07/31/2021, 3:17 PMNumber(guild)
and it still sees it as text :/Khan W
07/31/2021, 3:18 PMScott P
07/31/2021, 3:19 PMguild
, startDates
, endDates
defined as)?Khan W
07/31/2021, 3:23 PMguild
is an ID and is a string, so I probably should be typecasting it anyways. It looks like 752987588683366500
startDates
and endDates
are just [new Date()]
for now while I was testing it.Scott P
07/31/2021, 3:25 PMnew Date()
returns a verbose human friendly date. Adding .toISOString()
converts it into something that should be understandable to PostgresScott P
07/31/2021, 3:25 PMKhan W
07/31/2021, 3:25 PMKhan W
07/31/2021, 3:27 PMjavascript
.rpc("getEmptyStats", {
guild: Number(guild),
startDates: startDates.map((d) => d.toISOString()),
endDates: endDates.map((d) => d.toISOString()),
dateCount: Number(startDates.length),
})
Scott P
07/31/2021, 3:30 PMstart_dates
, end_dates
, date_count
) in the stored function as well as in your RPC args, does that work?Khan W
07/31/2021, 3:35 PMKhan W
07/31/2021, 3:42 PMKhan W
07/31/2021, 3:45 PMKosh
07/31/2021, 6:49 PMKhan W
07/31/2021, 7:48 PMKhan W
07/31/2021, 7:48 PMKosh
07/31/2021, 7:49 PMburggraf
07/31/2021, 10:24 PM