Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with NestJS #34

Open
watch-janick opened this issue Jun 25, 2024 · 0 comments
Open

Problem with NestJS #34

watch-janick opened this issue Jun 25, 2024 · 0 comments

Comments

@watch-janick
Copy link

Hello!

Did anyone already used this plugin successfully with NestJS?

I'm following NestJS Mongoose documentation to add the plugin to my schema but it doesn't work.

In my module:

@Module({
  imports: [
    MongooseModule.forFeatureAsync([
      {
        name: Passage.name,
        useFactory: () => {
          const schema = PassageSchema
          schema.plugin(require('mongoose-slug-updater'))
          return schema
        },
      },
    ]),
  ],
  controllers: [PassageController],
  providers: [PassageService],
})
export class PassageModule {}

In my schema:

@Prop({
  // required: true,
  unique: true,
  slug: ['field1', 'field2', 'field3'],
})
slug: string

Every time I create an instance of it, it doesn't add the slug at all to the database and on the second occurrence I run into a duplicate error, so it looks like the plugin doesn't have any effect.

Anyone figured it out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant