npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@z-brain/typeorm-postgres-camelcase-naming-strategy

v1.0.18

Published

Pascal/Camel Case naming for everything in the PostgreSQL

Downloads

14

Readme

Z-Brain TypeORM PostgreSQL Camelcase Naming Strategy

Pascal/Camel Case naming for everything in the PostgreSQL

Notice: If you have any propositions feel free to make an issue or create a pull request.

Features

  • All constraint names appended with 8-char hash for uniqueness. Example: eed18e0e
  • All names trimmed to 63 bytes including 8-char hash if the name is too long (in most cases length === bytes number, however not always).
  • There is an ability to have some suffixes to entity classes and omit these suffixes in the DB table names.
    Example: PublicTradeEntity -> PublicTrades (default entity suffix is Entity)
  • There is an ability to have some in-db suffixes on entity classes that should not be pluralized and should be added as is to the DB table names.
    Example: PublicTradeZipEntity -> PublicTradesZip (default in-db suffix is Zip)

Naming entity | Case | Examples --------------------|-------------------------------------------------------|-------- Table | PascalCase | Users, MySuperTable Column | CamelCase | id, mySuperColumn Enum | (not supported by TypeORM yet) | Primary Key | PK_{table}_{cols}_{hash} | PK_Instruments_id_bd441074, PK_MySuperTable_email,pwdHash_d1d1d1d1 Unique Constrain | UQ_{table}_{cols}_{hash} | UQ_Instruments_code_051d8d38, UQ_MySuperTable_firstName,lastName_d1d1d1d1 Default Constrain | DF_{table}_{col}_{hash} | DF_Users_email_d1d1d1d1, DF_MySuperTable_firstName_d1d1d1d1 Relation Constrain | REL_{table}_{cols}_{where}_{hash} | TODO example Check Constrain | CHK_{table}_{expression}_{hash} | TODO example Exclusion Constrain | XCL_{table}_{expression}_{hash} | TODO example Foreign Key | FK_{table}_{targetTable}_{cols}_{targetCols}_{hash} | FK_TradingPairs_Instruments_quotedInstrumentId_id_fc68de3f Index | IDX_{table}_{cols}_{hash} | IDX_Tickers_exchangeId,symbol_c8090854 Unique Index | UQIDX_{table}_{cols}_{hash} | UQIDX_Tickers_exchangeId,symbol_c8090854

How to use

Installing

yarn add @z-brain/typeorm-postgres-camelcase-naming-strategy
or
npm i -s @z-brain/typeorm-postgres-camelcase-naming-strategy

Configuring

/ormconfig.ts

import { TypeORMPostgresCamelCaseNamingStrategy } from '@z-brain/typeorm-postgres-camelcase-naming-strategy';

// Store an instance separately for reuse methods in you app
export const typeORMNamingStrategy = new TypeORMPostgresCamelCaseNamingStrategy();

// TypeORM connection config for PostgreSQL
export const defaultConnection: ConnectionOptions = {
  // ...
  namingStrategy: typeORMNamingStrategy,
};

module.exports = [defaultConnection];

Development notes

Quick Start

cd /code/z-brain
git clone [email protected]:z-brain/typeorm-postgres-camelcase-naming-strategy.git
cd typeorm-postgres-camelcase-naming-strategy
yarn install

How to use NodeJS version from the .nvmrc

  1. Install NVM

  2. Use .nvmrc file one of the next ways:

    • Execute nvm use in the project root directory
    • Install NVM Loader and your .nvmrc will be loaded automatically when you open the terminal. NVM Loader demo

How to make a build

npm run build

How to run lint

  • Just show problems npm run lint
  • Fix problems if it is possible npm run lint:fix

How to run tests

  • All tests

    npm run test
    npm run test:watch

  • Specific tests

    npm run test -- src/my.spec.ts
    npm run test:watch -- src/my.spec.ts

How to build and publish NPM package

NPM Token: 367a...ce73

CI configuration details here: .github/workflows/npmpublish.yml

yarn run pre-push \
&& npm version patch -m 'Update package version version to %s' \
&& yarn run gen-public-package.json \
&& cp README.md dist/ \
&& npm publish dist --access public \
&& git push --no-verify && git push --tags --no-verify

Author

| Anton Korniychuk | | :---: |