How to use the inflection.tableize function in inflection

To help you get started, we’ve selected a few inflection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mathewdgardner / knex-supermodel / lib / util.js View on Github external
static table(thiz) {
    if (thiz.constructor.name === 'Function') {
      // static context
      return inflection.tableize(thiz.name);
    }

    // non-static context
    return inflection.tableize(thiz.constructor.name);
  }
github eps1lon / poe-db / src / model / SequelizeThroughModel.js View on Github external
tableName() {
    // TODO strategy to shorten names to 64 chars
    return tableize(
      singularize(
        this.sourceModelName() +
          '_' +
          this.from_field.name.replace(/Keys([0-9]*)$/, '$1'),
      ),
    );
  }
github cube-js / cube.js / packages / cubejs-schema-compiler / scaffolding / ScaffoldingTemplate.js View on Github external
resolveTableName(tableName) {
    const tableParts = tableName.split('.');
    if (tableParts.length === 2) {
      this.scaffoldingSchema.resolveTableDefinition(tableName);
      return tableName;
    } else if (tableParts.length === 1) {
      const schema = Object.keys(this.dbSchema).find(schema => this.dbSchema[schema][tableName] || this.dbSchema[schema][inflection.tableize(tableName)]);
      if (!schema) {
        throw new UserError(`Can't find any table with '${tableName}' name`);
      }
      if (this.dbSchema[schema][tableName]){
        return `${schema}.${tableName}`;
      }
      if (this.dbSchema[schema][inflection.tableize(tableName)]){
        return `${schema}.${inflection.tableize(tableName)}`;
      }
    } else {
      throw new UserError(`Table names should be in  or .<table></table><table></table> format`);
    }
  }
github cube-js / cube.js / packages / cubejs-schema-compiler / scaffolding / ScaffoldingTemplate.js View on Github external
resolveTableName(tableName) {
    const tableParts = tableName.split('.');
    if (tableParts.length === 2) {
      this.scaffoldingSchema.resolveTableDefinition(tableName);
      return tableName;
    } else if (tableParts.length === 1) {
      const schema = Object.keys(this.dbSchema).find(schema =&gt; this.dbSchema[schema][tableName] || this.dbSchema[schema][inflection.tableize(tableName)]);
      if (!schema) {
        throw new UserError(`Can't find any table with '${tableName}' name`);
      }
      if (this.dbSchema[schema][tableName]){
        return `${schema}.${tableName}`;
      }
      if (this.dbSchema[schema][inflection.tableize(tableName)]){
        return `${schema}.${inflection.tableize(tableName)}`;
      }
    } else {
      throw new UserError(`Table names should be in  or .<table></table><table></table> format`);
    }
  }
github cube-js / cube.js / packages / cubejs-schema-compiler / scaffolding / ScaffoldingTemplate.js View on Github external
      const schema = Object.keys(this.dbSchema).find(schema => this.dbSchema[schema][tableName] || this.dbSchema[schema][inflection.tableize(tableName)]);
      if (!schema) {
github eps1lon / poe-db / src / model / SequelizeBaseModel.js View on Github external
static tableCasing(model_name) {
    return tableize(model_name);
  }
github wearevolt / mobx-model / src / base_model.js View on Github external
get: function() {
    return this._urlRoot ? this._urlRoot : '/'+tableize(this.modelName || this.name);
  },
  set: function(value) {
github martijndeh / fire / lib / modules / models / property-types.js View on Github external
associatedProperty.options.relationshipVia = property;
						property.options.relationshipVia = associatedProperty;
					}
				}

				if(associatedModel) {
					return {
						index: 999,
						clause: Table.keywords.References(associatedModel.getTableName()),
						dataType: 'UUID'
					};
				}
				else {
					return {
						index: 999,
						clause: Table.keywords.References(inflection.tableize(property.options.referenceName)),
						dataType: 'UUID'
					};
				}
			}, [modelNameOrModel, options]);
		}
github capitalone / oas-nodegen / lib / template-engines / handlebars.js View on Github external
Handlebars.registerHelper('tableize', function(value, options) {
  return value != null ? inflection.tableize(value) : null;
});