In MySQL, I successfully created a database named refy
with a single table labeled app
.
https://i.sstatic.net/BI8VD.png
My current focus is on utilizing NestJS to retrieve all columns from the mentioned table:
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { App } from 'src/database/refy/app.entity';
@Controller()
export class AppController {
constructor(private readonly refyService: AppService) {}
@Get('/refy')
findAll(): Promise<App[]> {
return this.refyService.findAll();
}
}
The entity file structure includes:
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
@Entity({name: 'app'})
export class App {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
webhookSecretKey: string;
@Column()
webhookUrl: string;
@Column()
clientId: string;
@Column()
clientSecretKey: string;
}
Even though the database connection seems intact and operational, Postman returns a 500 error when retrieving data:
https://i.sstatic.net/H4b7y.png
An error message appears in the terminal debug:
EntityMetadataNotFoundError: No metadata for "App" was found
The desired data output format should resemble this:
{
"webhookSecretKey": "1",
"webhookUrl": "2",
"clientId": "3",
"clientSecretKey": "4",
"id": 5,
"name": "6"
}