async function _resolveConflicts() {
    // Check first if we've used this base name before for the same target
    let slugs = await ThingSlug
      .filter({
        baseName: slug.name,
        thingID: slug.thingID
      })
      .orderBy(r.desc('createdOn'))
      .limit(1);

    if (slugs.length)
      return slugs[0]; // Got a match, no need to save -- just re-use :)

    // Widen search for most recent use of this base name
    slugs = await ThingSlug
      .filter({
        baseName: slug.name
      })
      .orderBy(r.desc('createdOn'))
      .limit(1);

    let latestQualifierStr;
    if (slugs.length && !isNaN(+slugs[0].qualifierPart))
      latestQualifierStr = String(+slugs[0].qualifierPart + 1);
    else
      latestQualifierStr = '2';
    slug.name = `${slug.name}-${latestQualifierStr}`;
    slug.qualifierPart = latestQualifierStr;
    return await slug.save();
  }
/**
   * Resolves naming conflicts by creating a new slug with a numeric qualifier
   * if needed.
   *
   * @memberof ThingSlug
   * @returns {ThingSlug}
   *  the best available slug to use
   * @inner
   * @protected
   */
Resolves naming conflicts by creating a new slug with a numeric qualifier
if needed.

@memberof ThingSlug
@returns {ThingSlug}
the best available slug to use
@inner
@protected
Resolves naming conflicts by creating a new slug with a numeric qualifier if needed . @memberof ThingSlug @returns { ThingSlug } the best available slug to use @inner @protected
async function _resolveConflicts() {
    let slugs = await ThingSlug
      .filter({
        baseName: slug.name,
        thingID: slug.thingID
      })
      .orderBy(r.desc('createdOn'))
      .limit(1);
    if (slugs.length)
      return slugs[0]; 
    slugs = await ThingSlug
      .filter({
        baseName: slug.name
      })
      .orderBy(r.desc('createdOn'))
      .limit(1);
    let latestQualifierStr;
    if (slugs.length && !isNaN(+slugs[0].qualifierPart))
      latestQualifierStr = String(+slugs[0].qualifierPart + 1);
    else
      latestQualifierStr = '2';
    slug.name = `${slug.name}-${latestQualifierStr}`;
    slug.qualifierPart = latestQualifierStr;
    return await slug.save();
  }
async function _resolveConflicts ( ) { let slugs = await ThingSlug . filter ( { baseName : slug . name , thingID : slug . thingID } ) . orderBy ( r . desc ( 'createdOn' ) ) . limit ( 1 ) ; if ( slugs . length ) return slugs [ 0 ] ; slugs = await ThingSlug . filter ( { baseName : slug . name } ) . orderBy ( r . desc ( 'createdOn' ) ) . limit ( 1 ) ; let latestQualifierStr ; if ( slugs . length && ! isNaN ( + slugs [ 0 ] . qualifierPart ) ) latestQualifierStr = String ( + slugs [ 0 ] . qualifierPart + 1 ) ; else latestQualifierStr = '2' ; slug . name = ` ${ slug . name } ${ latestQualifierStr } ` ; slug . qualifierPart = latestQualifierStr ; return await slug . save ( ) ; }
Resolves naming conflicts by creating a new slug with a numeric qualifier
 if needed.
Resolves naming conflicts by creating a new slug with a numeric qualifier if needed .
// Check first if we've used this base name before for the same target // Got a match, no need to save -- just re-use :) // Widen search for most recent use of this base name