const modelTable = ({ name, snake, singularTableNames }) => { const casedName = snake ? Case.snake(name) : Case.camel(name) return singularTableNames ? singularize(casedName) : pluralize(casedName) }
const validateIdentifierLength = identifier => pluralize(Case.snake(identifier)).length <= MAX_SQL_IDENTIFIER_LENGTH
/** Exposes a pluralised version of the models name Matches up with jsonapi specs `type` attribute Example: for a model `post`, type would be `posts` @property type @static @public @return {string} model type */ static get type () { const nameWithoutModel = this.name.replace('Model', '') const nameUnderscored = underscore(nameWithoutModel) const nameDasherized = dasherize(nameUnderscored) return pluralize(nameDasherized) }
/** Table name for model of the form lowercase, pluralized with underscores separating words Calculated from models class name with `Model` stripped off the end Example: For model MyPostModel, tablename would be my_posts @property tableName @static @public @return {string} table name for model */ static get tableName () { const nameWithoutModel = this.name.replace('Model', '') const nameUnderscored = underscore(nameWithoutModel) return pluralize(nameUnderscored) }