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

Slugs for subdocs #32

Open
phex85 opened this issue Apr 24, 2017 · 1 comment
Open

Slugs for subdocs #32

phex85 opened this issue Apr 24, 2017 · 1 comment

Comments

@phex85
Copy link

phex85 commented Apr 24, 2017

Hi,

I'm trying to get slugs for subdocs to work but I get an error, what I currently have is:

import mongoose from 'mongoose';
import URLSlugs from 'mongoose-url-slugs'

const Schema = mongoose.Schema;

const subTypeSchema = new Schema({
    name: {type: 'String', required: false},
});

subTypeSchema.plugin(URLSlugs('name'));

const productSchema = new Schema({
    name: { type: 'String', required: true },
    subtypes: [subTypeSchema],
});

productSchema.plugin(URLSlugs('name'));

export default mongoose.model('Product', productSchema);

I get the following error:

node_modules/mongoose-url-slugs/index.js:161
model.find(q, fields).exec(function(e, docs) {TypeError: : model.find is not a function

What am I doing wrong?

Node version 7.6.0
MongoDB shell version v3.4.4
Mongoose version ^4.4.20

@talha-asad
Copy link
Owner

Please submit a reproduction, you seem to be using ES6 syntax.

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

2 participants