How to use the snake-case.snakeCase function in snake-case

To help you get started, we’ve selected a few snake-case 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 adonisjs / adonis-lucid / src / Orm / Relations / ManyToMany / index.ts View on Github external
)

    /**
     * Parent model and it's foreign key in pivot table
     */
    this.localKey = this._options.localKey || this.model.$primaryKey
    this.pivotForeignKey = this._options.pivotForeignKey || snakeCase(
      `${this.model.name}_${this.model.$primaryKey}`,
    )
    this.pivotForeignKeyAlias = `pivot_${this.pivotForeignKey}`

    /**
     * Related model and it's foreign key in pivot table
     */
    this.relatedKey = this._options.relatedKey || this.relatedModel().$primaryKey
    this.pivotRelatedForeignKey = this._options.pivotRelatedForeignKey || snakeCase(
      `${this.relatedModel().name}_${this.relatedModel().$primaryKey}`,
    )
    this.pivotRelatedForeignKeyAlias = `pivot_${this.pivotRelatedForeignKey}`

    /**
     * Validate computed keys to ensure they are valid
     */
    this._validateKeys()

    /**
     * Keys for the adapter
     */
    this.localAdapterKey = this.model.$getColumn(this.localKey)!.castAs
    this.relatedAdapterKey = this.relatedModel().$getColumn(this.relatedKey)!.castAs
    this.booted = true
  }
github adonisjs / ace / src / Generator / StringTransformer.ts View on Github external
public changeCase (pattern?: 'pascalcase' | 'camelcase' | 'snakecase'): this {
    switch (pattern) {
      case 'camelcase':
        this.input = camelCase(this.input)
        return this
      case 'pascalcase':
        this.input = pascalCase(this.input)
        return this
      case 'snakecase':
        this.input = snakeCase(this.input)
        return this
      default:
        return this
    }
  }
github adonisjs / adonis-lucid / src / Orm / Relations / ManyToMany / index.ts View on Github external
public boot () {
    if (this.booted) {
      return
    }

    this.pivotTable = this._options.pivotTable || snakeCase(
      [this.relatedModel().name, this.model.name].sort().join('_'),
    )

    /**
     * Parent model and it's foreign key in pivot table
     */
    this.localKey = this._options.localKey || this.model.$primaryKey
    this.pivotForeignKey = this._options.pivotForeignKey || snakeCase(
      `${this.model.name}_${this.model.$primaryKey}`,
    )
    this.pivotForeignKeyAlias = `pivot_${this.pivotForeignKey}`

    /**
     * Related model and it's foreign key in pivot table
     */
    this.relatedKey = this._options.relatedKey || this.relatedModel().$primaryKey
    this.pivotRelatedForeignKey = this._options.pivotRelatedForeignKey || snakeCase(
      `${this.relatedModel().name}_${this.relatedModel().$primaryKey}`,
    )
    this.pivotRelatedForeignKeyAlias = `pivot_${this.pivotRelatedForeignKey}`

    /**
     * Validate computed keys to ensure they are valid
     */
github adonisjs / adonis-lucid / src / Orm / BaseModel / index.ts View on Github external
public static $addColumn (name: string, options: Partial) {
    const descriptor = Object.getOwnPropertyDescriptor(this.prototype, name)

    const column: ColumnNode = {
      primary: options.primary || false,
      castAs: options.castAs || snakeCase(name),
      hasGetter: !!(descriptor && descriptor.get),
      hasSetter: !!(descriptor && descriptor.set),
      serializeAs: options.serializeAs || snakeCase(name),
      serialize: options.serialize === false ? false : true,
    }

    /**
     * Set column as the primary column, when `primary` is to true
     */
    if (column.primary) {
      this.$primaryKey = name
    }

    this.$columns.set(name, column)
    this._mappings.cast.set(column.castAs!, name)
    this.$refs[name] = column.castAs
github adonisjs / adonis-lucid / src / Orm / BaseModel / index.ts View on Github external
return
    }

    this.$booted = true
    this.$primaryKey = this.$primaryKey || 'id'

    Object.defineProperty(this, '$refs', { value: {} })
    Object.defineProperty(this, '$columns', { value: new Map() })
    Object.defineProperty(this, '$computed', { value: new Map() })
    Object.defineProperty(this, '$relations', { value: new Map() })

    Object.defineProperty(this, '_hooks', { value: new Hooks(this.$container) })
    Object.defineProperty(this, '_mappings', { value: { cast: new Map() }})

    this.$increments = this.$increments === undefined ? true : this.$increments
    this.$table = this.$table === undefined ? pluralize(snakeCase(this.name)) : this.$table
  }
github adonisjs / adonis-lucid / src / Orm / Relations / ManyToMany / index.ts View on Github external
public boot () {
    if (this.booted) {
      return
    }

    this.pivotTable = this._options.pivotTable || snakeCase(
      [this.relatedModel().name, this.model.name].sort().join('_'),
    )

    /**
     * Parent model and it's foreign key in pivot table
     */
    this.localKey = this._options.localKey || this.model.$primaryKey
    this.pivotForeignKey = this._options.pivotForeignKey || snakeCase(
      `${this.model.name}_${this.model.$primaryKey}`,
    )
    this.pivotForeignKeyAlias = `pivot_${this.pivotForeignKey}`

    /**
     * Related model and it's foreign key in pivot table
     */
    this.relatedKey = this._options.relatedKey || this.relatedModel().$primaryKey
github adonisjs / adonis-lucid / src / Orm / Relations / HasManyThrough / index.ts View on Github external
/**
   * Foreign key on the `relatedModel`. This bounds the `throughModel` with
   * the `relatedModel`.
   */
  public throughForeignKey: string

  /**
   * Adapter key for the defined `throughForeignKey`
   */
  public throughForeignAdapterKey: string

  /**
   * Key to be used for serializing the relationship
   */
  public serializeAs = this._options.serializeAs || snakeCase(this.relationName)

  /**
   * A flag to know if model keys valid for executing database queries or not
   */
  public booted: boolean = false

  constructor (
    public relationName: string,
    private _options: ThroughRelationNode,
    public model: ModelConstructorContract,
  ) {
    this._ensureRelatedModel()
  }

  /**
   * Ensure that related model is defined, otherwise raise an exception, since
github adonisjs / adonis-lucid / commands / MakeMigration.ts View on Github external
toTableName (filename: string) {
          return tableName || snakeCase(filename.replace(prefix, ''))
        },
      })
github ember-cli / eslint-plugin-ember / lib / rules / routes-segments-snake-case.js View on Github external
const isNotSnakeCase = function(name) {
      return snakeCase(name) !== name;
    };
github adonisjs / adonis-lucid / src / Orm / Relations / ManyToMany / index.ts View on Github external
public pivotRelatedForeignKeyAlias: string

  /**
   * Pivot table for joining relationships
   */
  public pivotTable: string

  /**
   * Extra pivot columns to extra
   */
  public extrasPivotColumns: string[] = this._options.pivotColumns || []

  /**
   * Key to be used for serializing the relationship
   */
  public serializeAs = this._options.serializeAs || snakeCase(this.relationName)

  /**
   * A flag to know if model keys are valid for executing database queries or not
   */
  public booted: boolean = false

  constructor (
    public relationName: string,
    private _options: ManyToManyRelationNode,
    public model: ModelConstructorContract,
  ) {
    this._ensureRelatedModel()
  }

  /**
   * Ensure that related model is defined, otherwise raise an exception, since

snake-case

Transform into a lower case string with underscores between words

MIT
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis