#Nestjs Prisma Soft Delete Extension

5 messages · Page 1 of 1 (latest)

modest temple
#

Hello,

I implemented a soft delete package using 'prisma-extension-soft-delete', but I don't know where the problem is. Here is my code:

import { PrismaClient } from '@prisma/client';
import { createSoftDeleteExtension } from 'prisma-extension-soft-delete';

@Injectable()
export class DatabaseService extends PrismaClient implements OnModuleInit {
  constructor() {
    super();
    this.applySoftDeleteExtension();
  }

  private applySoftDeleteExtension() {
    const extendedPrisma = createSoftDeleteExtension({
      models: {
        Article: true,
        User: true,
      },
    });

    this.$extends(extendedPrisma);
  }

  async onModuleInit() {
    return await this.$connect();
  }
}```

I also tried inside the onModuleInit(), but it still doesn't work:

```@Injectable()
export class DatabaseService extends PrismaClient implements OnModuleInit {
  async onModuleInit() {
    this.$extends(createSoftDeleteExtension({
      models: {
        Article: true,
        User: true,
      },
    }));
    return await this.$connect();
  }
}```
stone river
#

#1178340768310636545 message
I'm not sure if this applies still but it seems to be the same case as above

modest temple
#

I will look into it, thank you 🙌🏽

stone river
#

no prob