PrismaP
Prisma2y ago
15 replies
Sabin Adams

Pulse Type

Is there a good way to get the type of a Prisma Client instance with Pulse before instantiating it?

For context, I have a class that will eventually have a member populated with a Pulse DB instance:

@Module({})
export class VendorModule implements OnModuleInit {
    private pulse: typeof pulseType;
    constructor(@Inject('PRISMA') private prisma: PrismaClient) {}

    async onModuleInit() {
        this.pulse = this.prisma.$extends(
            withPulse({
                apiKey: process.env.PULSE_API_KEY,
            }),
        );
        await this.setupListeners();
    }

    private async setupListeners() {
        this.pulse.user.stream(/*...*/);
    }
}
Was this page helpful?