1.0.20 • Published 2 years ago

@heorhii.sanchenko/typeorm v1.0.20

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@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)
})
1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago