I am building an angular 17 application with SSR enabled at the time of project initialization.
I am trying to use Prisma ORM to fetch data from Postgresql DB.
I am able to set up Prisma, my schema.prisma
file is created with all the schemas from the D.B., and in the Prisma studio, I can view all the table entries from the DB.
I have created a service to fetch data from DB using Prisma and injected this service on the frontend, in a component and received the following error:
Service.ts
import {
Injectable
} from '@angular/core';
import {
PrismaClient
} from '@prisma/client';
@Injectable({
providedIn: 'root',
})
export class OrmService {
private prisma: PrismaClient = new PrismaClient();
constructor() {}
getMovies() {
const predictions = this.prisma.movies;
console.log(predictions, 'clg pred');
return predictions;
}
}
Component.ts
import {
Component,
inject
} from '@angular/core';
import {
OrmService
} from '../../services/dbservice/orm.service';
@Component({
selector: 'app-categories',
standalone: true,
imports: [],
templateUrl: './categories.component.html',
styleUrl: './categories.component.scss',
})
export class CategoriesComponent {
prismaService = inject(OrmService);
item!: any;
predictions!: any;
ngOnInit() {
this.prismaService.getMovies();
}
}