Socket
Socket
Sign inDemoInstall

@heorhii.sanchenko/typeorm

Package Overview
Dependencies
46
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @heorhii.sanchenko/typeorm

Simple clone of TypeORM


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@heorhii.sanchenko/typeorm

This is a simple clone of TypeORM

Currently, it has no relations between tables and a limited choice of data types. Also, there are only 'save' and 'find' methods available on thr Repository class. Besides, it supports ony MySQL and Postgres as of now.

Here is a simple usage example:


import {Entity, PrimaryGeneratedColumn, Column, DataSource} from "@heorhii.sanchenko/typeorm";

@Entity('user')
export class User {
   @PrimaryGeneratedColumn()
   id: number

   @Column({notNull: true})
   name: string

   @Column()
   dob: Date
}

const myDataSource = new DataSource({
   type: "mysql",
   host: "localhost",
   database: "typeorm",
   password: "typeorm",
   logging: true
})

const main = async () => {
   try {
      await myDataSource.initialize()
      const userRepo = myDataSource.getRepository<User>(User)

      await userRepo.save({name: "Jorge", dob: new Date('2003-07-14')})
      await userRepo.save({name: "Paul", dob: new Date('2003-07-15')})
      await userRepo.save({name: "John", dob: new Date('2003-07-16')})
      await userRepo.save({name: "John", dob: new Date('2003-07-17')})
      await userRepo.save({name: "John", dob: new Date('2003-07-18')})

      const findResult = await userRepo.find({
         where: [
            {id: 1},
            {name: "John"}
         ]
      })

      console.log(findResult)

      const findResult2 = await userRepo.find({
         where: [
            {name: "John", dob: new Date('2003-07-17')}
         ]
      })

      console.log(findResult2)

      await myDataSource.destroy()
   } catch (e) {
      console.log(e)
      await myDataSource.destroy()
      process.exit(1)
   }
}

main().then(() => {
   process.exit(0)
})

Keywords

FAQs

Last updated on 12 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc