0.0.4 • Published 3 years ago

te2ys v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

te2ys

TypeORM Entity 2 Yup Schema

Usage

import te2ys from 'te2ys'
import { User } from 'User.entity.ts'
import { getRepository } from 'typeorm'

const userRepository = getRepository( User, 'default' )

const userSchemas = te2ys( User, { connectionName: 'default' } )

const userInsertSchema = userSchemas.insert()

userInsertSchema.validate( {
  name: 'Some name',
  email: 'some-email@some.com'
} )
  .then( result => userRepository.insert( result ) )
  .catch( ( yupValidateError ) => {} )

userInsertSchema.validate( [ {
  name: 'Some another name',
  email: 'some-another-email@some.com'
}, {
  name: 'Another some',
  email: 'another-some@some.com'
} ] )
  .then( result => userRepository.insert( result ) )
  .catch( ( yupValidateError ) => {} )
0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago