dev Joakim Pedersen
02/01/2023, 10:15 AMakella
02/01/2023, 10:32 AMjavascript
let insert_result = await supabase.from('items').insert({'name': 333})
this code works fine when if run it in my client-side components.
But when i do it in Next.js api handler, i get this response for insert:
javascript
insert_result : {
"error": {
"code": "PGRST102",
"details": null,
"hint": null,
"message": "Content-Type not acceptable: application/json, text/plain"
},
"data": null,
"count": null,
"status": 400,
"statusText": "Bad Request"
}
Select request to supabase works just fine in handler, only insert one breaks, and i cant quite understand what this error says to me.
here is full code of my api/insertItem.js
javascript
import {supabase} from './supabase'
const handler = async (req, res) => {
let insert_result = await supabase.from('items').insert({'name': 'whatever',})
res.send({message: 'ok ok',insert_result})
}
export default handler;
Lukas V
02/01/2023, 11:16 AMconst [selectedDate, setSelectedDate] = useState<Dayjs>(dayjs());
const handleDateChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setSelectedDate(dayjs(event.target.value));
};
Would be converted to UTC timezone once inserted into row?
So if you create an timestamp for an offer that ends 02 02 2023 8am in your timezone, each user will see a different ending based on their own timezone?hiroshi nishio
02/01/2023, 2:52 PMkevlust
02/01/2023, 4:36 PMSimon Jimenez Tamayo
02/01/2023, 4:52 PMAtrox
02/01/2023, 5:18 PMtsx
await supabase.from('posts').select('*, comments (*)');
Is there a way to get a count of the comments, rather than every single comment row, while still returning fields from posts
?Smardrengr
02/01/2023, 5:33 PMsql
I'd write profiles.games_remaining = profiles.games_remaining-1
but it does not appear you can do this with Supabase API? Or am I wrong?cncpowerhour
02/01/2023, 5:51 PMSTILLWATER;
02/01/2023, 6:24 PMawait supabase_connect.auth.admin.deleteUser(req.user.sub);
But it is not deleting user im passign the id of auth users tableVexoa
02/01/2023, 8:30 PMMofoga
02/01/2023, 8:35 PMBoogersLLC
02/01/2023, 8:50 PMleft join
?
For context, I want to return from the parent if the foreign table :
- Has a specific value
- Is missing
For example, the query I want to run is exactly:
sql
select * from DECKS as decks
left join spaced_repetition as sr on sr.notebook_id = decks.id
where decks.user_id = 'MY_ID'
and (sr.id is null or sr.status = 'INIT')
Without the left
, I lose all the rows where spaced_repetition
does not exist. i.e. has a null
id
Hypothetically, I guess I could just call this from a postgres function, but my codebase is already setup to use the select
so just wondering 🙂TheSecond
02/01/2023, 9:03 PMdrewbie
02/01/2023, 9:13 PMrpc
method on the JS client. However, when I don't add SECURITY DEFINER
to the function, i get null for auth.uid
. When I add it, its there. However I dont want to add SECURITY DEFINER
since this bypasses RLS policies for the tables being queried/inserted. Any ideas what I may be missing?
Here is my function
CREATE FUNCTION public.create_offer (offer_products jsonb, offer_message text = '')
RETURNS record
LANGUAGE plpgsql
SECURITY DEFINER
AS $$
DECLARE
offer record;
offer_product jsonb;
BEGIN
IF (LENGTH(offer_message) > 0) THEN
INSERT INTO offers (message, account_id)
VALUES (offer_message, auth.uid ())
RETURNING
* INTO offer;
ELSE
INSERT INTO offers (account_id)
VALUES (auth.uid ())
RETURNING
* INTO offer;
END IF;
FOR offer_product IN (
SELECT
JSONB_ARRAY_ELEMENTS(offer_products))
LOOP
IF offer_product ->> 'product_variant_option_id' IS NOT NULL THEN
INSERT INTO offer_products (product_variant_option_id, price, offer_id)
VALUES ((offer_product ->> 'product_variant_option_id')::uuid, (offer_product ->> 'price')::numeric, offer.id);
ELSE
INSERT INTO offer_products (product_id, price, offer_id)
VALUES ((offer_product ->> 'product_id')::uuid, (offer_product ->> 'price')::numeric, offer.id);
END IF;
END LOOP;
RETURN offer;
END;
$$;
Any help would be appreciated!Nin
02/01/2023, 9:26 PMAnarki
02/01/2023, 10:32 PMn10000k
02/01/2023, 11:18 PMmaglev
02/02/2023, 12:21 AM.select( `*, company_data(company_name)`)
.in('company_data.company_name', ['Target'])
Pythonic
02/02/2023, 4:10 AMpublic
schema with read and write disabled? Should I create a new schema called private
or something that only the server can access? Should I modify existing auth
schema?
Any tips appreciated.
Thankselliott
02/02/2023, 5:57 AMaltryne
02/02/2023, 7:05 AM.from('videos')
.select(`
uid,
title,
description,
language,
captions(language)
`)
,eq('captions.video_uid', 'uid')
And it doesn't return anything.
How can I add an ARRAY_AGG type column that will return all caption languages (one of the columns) in an array?
I can't seem to do this:
select v.uid, array_agg(c.language)
from videos v
join captions c on v.uid = c.video_uid
where uid = '12345'
group by v.uid
limit 1
culiao
02/02/2023, 7:05 AMLevissie
02/02/2023, 7:11 AMTwilkey(Limpious)
02/02/2023, 9:04 AM{
"status": true,
"response": {
"theme": {
"desc": "Description",
"name": "A theme name",
"author": "An author",
"version": "2.14.2",
"isparent": "Yes"
},
"plugins": [
{
"desc": "AMP for WP - Accelerated Mobile Pages for WordPress",
"name": "Accelerated Mobile Pages",
"author": "Ahmed Kaludi, Mohammed Kaludi",
"status": "Inactive",
"update": "Yes",
"version": "1.0.77.42",
"new_version": "1.0.79"
},
{
"desc": "Customize WordPress with powerful, professional and intuitive fields.",
"name": "Advanced Custom Fields PRO",
"author": "Delicious Brains",
"status": "Active",
"update": "No",
"version": "5.12.3",
"new_version": "-"
},
{
"desc": "Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.",
"name": "Akismet Anti-Spam",
"author": "Automattic",
"status": "Inactive",
"update": "Yes",
"version": "4.2.2",
"new_version": "5.0.2"
}
]
}
}
I need to be able to fetch each row that shares the value of the key name inside the sitedata.response.plugins array of objects.
I have tried many things suggested by people through my Google searches, but nothing works. The last thing I tried was this, but it returns an empty array.
let { data, error } = await supabase.from('sites')
.select('*')
.contains("sitedata", {"response:jsonb->plugins": [{"name": "Accelerated Mobile Pages"}]});
Fayyaz
02/02/2023, 9:33 AM_alex
02/02/2023, 9:45 AMhttps://app.supabase.com/project/<project-id>/database/tables
The exception is Application error: a client-side exception has occurred (see the browser console for more information).
and takes up the entire screen.Sreenivas
02/02/2023, 10:04 AMlogemann
02/02/2023, 10:13 AMdrg
02/02/2023, 12:47 PM