Closed dassennato closed 6 years ago
Hi,
I'm using 1.0.0 and consider this case:
const mongoose = require('mongoose'); const Schema = mongoose.Schema; const URLSlugs = require('mongoose-url-slugs'); let fooSchema = new Schema({ name: { type: String, required: true }, }); fooSchema.plugin(URLSlugs('name')); const Foo = mongoose.model('Foo', fooSchema); Foo.create({ name: 'Foo Bar' }) .then((foo) => { console.log(foo.slug); // ====> 'foo-bar', this slug is ok! return Foo.create({ name: 'Foo' }); }) .then((foo) => { console.log(foo.slug); // ====>'foo-2' was created but 'foo' was expected. });
If I invert the order, I first create 'Foo' and then 'Foo Bar' it works as expected.
Thanks!
hey @dassennato,
Seems you've found a bug, I would dig into this further over the week, in the meanwhile if you find a solution, please don't hesitate to submit a PR.
I made a fix https://github.com/talha-asad/mongoose-url-slugs/pull/36
Merged and test added
Hi,
I'm using 1.0.0 and consider this case:
If I invert the order, I first create 'Foo' and then 'Foo Bar' it works as expected.
Thanks!