How to use snake-case - 10 common examples

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 charlieschwabacher / gestalt / packages / gestalt-postgres / src / generateDatabaseInterface.js View on Github external
definition.fields.forEach(field => {
    if (
      field.directives &&
      field.directives.some(directive => directive.name.value === 'index') &&
      // a uniqueness constraint implies an index, so if the @unique directive
      // is present we don't need to add an additional one
      !field.directives.some(directive => directive.name.value === 'unique')
    ) {
      indices.push({table, columns: [snake(field.name.value)]});
    }
  });
  return indices;
github charlieschwabacher / gestalt / packages / gestalt-postgres / src / generateRelationshipResolver.js View on Github external
export function orderFromOrderArgument(order: string): Order {
  return {
    column: (
      order == null || order === 'ASC' || order === 'DESC'
      ? 'seq'
      : snake(order.replace(/_ASC$|_DESC$/, ''))
    ),
    direction: order && order.match(/DESC$/) ? 'DESC' : 'ASC',
  };
}
github Yoctol / bottender / src / database / scoped.js View on Github external
constructor(db, scope) {
    this._db = db;
    this._scope = snakeCase(scope);
  }
github rethinkdb / horizon / client / src / ast.js View on Github external
function checkIfLegalToChain(key) {
  if (this._legalMethods.indexOf(key) === -1) {
    throw new Error(`${key} cannot be called on the current query`)
  }
  if (snakeCase(key) in this._query) {
    throw new Error(`${key} has already been called on this query`)
  }
}
github charlieschwabacher / gestalt / packages / gestalt-postgres / src / generateDatabaseInterface.js View on Github external
export function columnFromFieldDefintion(definition: FieldDefinition): Column {
  const isId = definition.name.value === 'id';
  return {
    name: snake(definition.name.value),
    type: columnTypeFromGraphQLType(definition.type),
    primaryKey: isId,
    nonNull: isNonNullType(definition.type),
    unique: definition.directives.some(d => d.name.value === 'unique'),
    defaultValue: isId ? 'gen_random_uuid()' : null,
    references: null,
  };
}
github charlieschwabacher / gestalt / packages / gestalt-cli / src / migrate.js View on Github external
async function updateDatabaseSchema(
  localPackage: Object,
  schemaText: string,
  {url}: {url: string}
): Promise<*> {
  let databaseUrl;

  if (url) {
    databaseUrl = url;
  } else {
    const prompt = await get({
      name: 'databaseUrl',
      message: 'what is the url to your database?',
      default: `postgres://localhost/${snake(localPackage.name)}`,
    });
    databaseUrl = prompt.databaseUrl;
  }

  const existingSchema = await readExistingDatabaseSchema(databaseUrl);

  const ast = parse(schemaText);
  const {objectDefinitions, relationships} = databaseInfoFromAST(ast);
  const {db, schema} = generateDatabaseInterface(
    databaseUrl,
    objectDefinitions,
    relationships
  );

  const {sql} = generateDatabaseSchemaMigration(schema, existingSchema);
github ChainSafe / lodestar / packages / eth2.0-utils / src / converters / json.ts View on Github external
export function toJson(o: object): object {
  o = {...o};
  for (const key in o) {
    const newKey = snakeCase(key);
    //@ts-ignore
    o[newKey] = o[key] !== null ? serializeToJson(o[key]) : null;
    if (newKey !== key) {
      //@ts-ignore
      delete o[key];
    }
  }
  return o;
}
github charlieschwabacher / gestalt / packages / gestalt-postgres / src / DB.js View on Github external
      .map((key, i) => `${snake(key)} = $${i + initialEscape + 1}`)
      .join(' AND ')
github ringa-js / ringa / src / Controller.js View on Github external
types.forEach(type => {
      let TYPE_SNAKE_CASE = snakeCase(type).toUpperCase();

      if (this.constructor[TYPE_SNAKE_CASE]) {
        return;
      }

      this.constructor[TYPE_SNAKE_CASE] = this[TYPE_SNAKE_CASE] = type;
    });
  }
github charlieschwabacher / gestalt / packages / gestalt-postgres / src / resolveRelayConnection.js View on Github external
export function orderFromOrderArgument(defaultOrder: Order, order: ?string): Order {
  if (order == null) {
    return defaultOrder;
  }

  return {
    column: (
      order === 'ASC' || order === 'DESC'
      ? defaultOrder.column
      : snake(order.replace(/_ASC$|_DESC$/, ''))
    ),
    direction: order && order.match(/DESC$/) ? 'DESC' : 'ASC',
  };
}

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