1.0.20 • Published 3 years ago

@heorhii.sanchenko/typeorm v1.0.20

Weekly downloads
-
License
ISC
Repository
github
Last release
3 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

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago