Namespace: SlugName

SlugName

Helper/handler functions for dealing with unique "slugs", i.e. short human-readable strings that are part of the URL, e.g., for review subjects and teams.

Source:

Methods

(static) getUpdateSlugHandler(spec) → {function}

Get a handler that can be attached to a model as an instance method for creating/updating human-readable string (slug) used in URL to identify the document.to create/update a unique

Parameters:
Name Type Description
spec Object

specification for the handler

Properties
Name Type Description
SlugModel Model

table that holds our slugs

slugForeignKey String

key used in slug table to identify foreign document

slugSourceField String

field in document table that is used to generate slug names -- assumed to be a field containing multingual string objects

Source:
Returns:
Type
function

(async, inner) _updateSlug(userIDopt, language) → {model}

Handler for generating a slug from a configured multilingual string field, assigning it and saving it. Re-uses existing slugs that have previously pointed to the same document where posisble.

Parameters:
Name Type Attributes Description
userID String <optional>

user ID to attribute to this slug

language String

which language should we look up from the source field? if it is not identical to the .originalLanguage field for the document, we will not modify the slug.

Source:
Returns:

the original document with the slug name assigned to its .canonicalSlugName field.

Type
model