Is it possible to do resource embedding on filters...
# help
d
Is it possible to do resource embedding on filters when running a delete operation? I want to delete an entry from a table based on embedded columns from a foreign table
n
Hello @da newb! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
s
@da newb Yes, that's possible. What have you tried? You would need to use: https://postgrest.org/en/stable/api.html#embedding-with-top-level-filtering
n
da newb (2022-06-04)
d
Hi, I have a table layout like this
Copy code
create table discovery.nft_contracts (
    id serial primary key,
    chain_id integer not null,
    -- TODO(dbmikus) we should lowercase this
    contract_address text not null
);

create table discovery.nfts (
    id bigserial primary key,
    nft_contract_id int references discovery.nft_contracts not null,
    token_id util.uint256 not null
);

create table public.bookmarks (
    user_id uuid references auth.users not null,
    nft_id bigint references discovery.nfts (id) not null,
    created_at timestamptz not null default now(),
    updated_at timestamptz not null default now(),

    primary key (user_id, nft_id)
);
I would like to be able to delete a bookmark by specifying
chain_id, contract_address, token_id
instead of by
nft_id
This is what I had to delete via
nft_id
Copy code
const resp = await this.supabaseClient
      .from<sbtypes.definitions['bookmarks']>(LIKES_TABLE)
      .delete()
      .match({ user_id: args.user_id, nft_id: args.nft_id })
s
@da newb I see. Actually I've noticed that right now you'd need a function for this. However it will be possible once this issue is solved: https://github.com/PostgREST/postgrest/issues/2323