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

Possible to use the plugin on a subdocument? #41

Open
trekinbami opened this issue Dec 21, 2017 · 3 comments
Open

Possible to use the plugin on a subdocument? #41

trekinbami opened this issue Dec 21, 2017 · 3 comments

Comments

@trekinbami
Copy link

trekinbami commented Dec 21, 2017

Hi,

const CourseSchema = new Schema({
  title: {
    type: String,
    required: true
  },
  videos: [VideoSchema],
});

CourseSchema.plugin(URLSlugs('title');
const Course = mongoose.model('course', CourseSchema);

module.exports = Course;

This is pretty obvious. This is the model for a course.

But now I want to run the plugin for the VideoSchema (which doesn't have a Model), because the videos also have title that needs to be slug-i-fied (don't know if that's a word).

Is this possible?

@talha-asad
Copy link
Owner

talha-asad commented Dec 21, 2017 via email

@trekinbami
Copy link
Author

trekinbami commented Dec 21, 2017

I tried

CourseSchema.plugin(URLSlugs('videos.title', { path: 'videos.slug' }));

But didn't seem to do anything, unfortunately.

@hakkurishian
Copy link

Is there any update on this? I'm facing the same issue. If not, is it possible to generate slugs manually in the same way as they are created automatically using the packages API?

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

3 participants