I just create a Supabase DB using NestJS and TypeORM. I have some entities like this:
@Entity()
export class UserService {
@PrimaryGeneratedColumn()
id: number;
@OneToOne(type => User)
user: User;
@OneToOne(type => Service)
service_id: ForeignKeyMetadata;
@Column('text')
token: string;
@Column({ default: () => 'CURRENT_TIMESTAMP', type: 'timestamp' })
created: Date;
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP' })
updated: Date;
}
I'm trying to link user Field to User table, that is the table for user management in supabase.
I import this like:
import { Entity, Column, PrimaryGeneratedColumn, OneToOne } from 'typeorm';
import { ForeignKeyMetadata } from 'typeorm/metadata/ForeignKeyMetadata';
import { User } from '@supabase/supabase-js';
import { Service } from './service.entity';
but, User is an interface, so I can't use it in (also i'm not sure i need to import that).
In the official documentation, they llink tables like:
create table public.profiles (
id uuid not null references auth.users on delete cascade,
first_name text,
last_name text,
primary key (id)
);
alter table public.profiles enable row level security;
https://supabase.com/docs/guides/auth/managing-user-data?language=js
How can i do that, using NestJS and TypeORM ? Remember, the goal of this topic is not to link table to an other table using foreign key. The goal is to link table to Auth.user table that is directly in Supabase.