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

@scaleleap/typeorm

v1.1.15

Published

Enhanced and pre-configured TypeORM version with helpers included.

Downloads

31

Readme

📦 @scaleleap/typeorm

Enhanced and pre-configured TypeORM version with helpers included.


Download & Installation

$ npm i -s typeorm @scaleleap/typeorm

Create a config file in src/ormconfig.ts:

import { createConnectionOptions } from '@scaleleap/typeorm'

export = createConnectionOptions({
  // ... your config
})

Add the following to package.json:

{
  "scripts": {
    "typeorm": "typeorm-cli -f src/ormconfig.ts"
  }
}

Add the following to tsconfig.json:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
  },
}

Usage

Our package is a superset of typeorm, and thus you can use it exactly the same way as you would use typeorm directly.

import { createConnection } from '@scaleleap/typeorm'

Enhancements

typeorm-cli CLI replacement that supports TypeScript config files

typeorm-cli migration:generate ...

Here is a list of features and enhancements over stock typeorm:

createConnectionOptions factory function

Factory function for creating TypeORM configuration object. Suitable to be passed to createConnection function or inside ormconfig.ts.

Logger

You can pass an instance of @scaleleap/logger to createConnectionOptions factory to be used as a custom logger for TypeORM.

Naming Strategy

This package is pre-configured to use a custom naming strategy that is more descriptive and sane than TypeORM default. It uses meaningful identity naming. E.g. instead of PK_adc83b19e793491b1c6ea0fd8b46cd9f32e592fc it will use pk_user_id_a4378d.

createConnection factory function

The stock createConnection is amended to return a connection with enhanced type that exposes PostgreSQL connection Pool via connection.driver.master. The prop was already there, we are just casting the connection and driver to the right type to expose it correctly.

createEncryptionTransformer factory function

Creates a column transformer which can then be used to encrypt data.

export class Encrypted {
  // ...

  @Column({ transformer: createEncryptionTransformer(encryptionKey) })
  public secret!: string
}

migration:generate

The migration:generate command has been enhanced to create prettified SQL.

TestDatabaseConnection class for tests

// pass the same params as `createConnectionOptions`
const tdc = new TestDatabaseConnection({
  connectionOptions: {
    entities: [User],
  },
})

// 1. Creates a test database
// 2. Returns TypeORM connection
const connection = await tdc.setup()

//
// run the tests here...
//

// 1. Destroys the test database
// 2. Disconnects
await tdc.teardown()

upsert function - WIP

Technically the code is ready. But an issue with TypeORM is preventing us from using it.

New features

QidTransformer

A transformer to convert UUID strings to Qid and back.

See test/entities/qid.ts for usage example.

Contributing

This repository uses Conventional Commit style commit messages.

Authors or Acknowledgments

License

This project is licensed under the MIT License.

Badges

GitHub Workflow Status NPM License Coveralls Semantic Release