Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support array of ValueTransformer in column options #4007

Closed
Samox opened this issue Apr 17, 2019 · 1 comment · Fixed by #4009
Closed

Support array of ValueTransformer in column options #4007

Samox opened this issue Apr 17, 2019 · 1 comment · Fixed by #4009

Comments

@Samox
Copy link

Samox commented Apr 17, 2019

Issue type:

[ ] question
[ ] bug report
[x] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[ ] latest
[ ] @next
[x] ^0.2.14 (or put your version here)

Steps to reproduce or a small repository showing the problem:

Hi, I'd like to be able to apply multiple ValueTransformers to a field:

import { ValueTransformer } from "typeorm";

export const lowercase: ValueTransformer = {
    to: (entityValue: string) => { return entityValue.toLocaleLowerCase() },
    from: (databaseValue: string) => { return databaseValue }
}

export const encrypt: ValueTransformer = {
    to: (entityValue: string) => { return crypto.encrypt(entityValue) },
    from: (databaseValue: string) => { return crypto.decrypt(databaseValue) }
}

And use them like this:

  @Column({ unique: true, transformer: [lowercase, encrypt] })
  email: string;

Is it on the road map ?
I'd be more than happy to do a PR if this sounds a good idea to you !😇

Thanks

@Samox
Copy link
Author

Samox commented Apr 17, 2019

I made a POC for Postgres and 2 value transformers #4009

@Samox Samox changed the title Apply array of ValueTransformer in column options Support array of ValueTransformer in column options Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant