lib/mongoose-slug-hero.js
function buildSlug(data, update, done) {
    var opt = buildOptions(data)

    // store old slug
    if (update) {
      _.get(data, slugsFieldName).push(_.get(data, slugFieldName))
    }

    // Get next counter within scope
    Counters.findByIdAndUpdate(
      opt.key,
      { $inc: { seq: 1 } },
      { upsert: true, new: true },
      function(err, res) {
        if (err) {
          throw err
        }

        var seq = res.seq,
          slg = opt.slg

        // If found more than one, then add suffix to the slug
        if (seq > 1) {
          slg = slg + '-' + seq
        }

        // store new slug
        _.set(data, slugFieldName, slg)

        done(null, slg)
      }
    )
  }
function buildSlug(data, update, done) {
    var opt = buildOptions(data)

    // store old slug
    if (update) {
      _.get(data, slugsFieldName).push(_.get(data, slugFieldName))
    }

    // Get next counter within scope
    Counters.findByIdAndUpdate(
      opt.key,
      { $inc: { seq: 1 } },
      { upsert: true, new: true },
      function(err, res) {
        if (err) {
          throw err
        }

        var seq = res.seq,
          slg = opt.slg

        // If found more than one, then add suffix to the slug
        if (seq > 1) {
          slg = slg + '-' + seq
        }

        // store new slug
        _.set(data, slugFieldName, slg)

        done(null, slg)
      }
    )
  }
Build slug