0.7.0 • Published 2 months ago

@volcanicminds/typeorm v0.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

License: MIT opensource volcanic-typeorm npm

volcanic-database-typeorm

Based on

Based on TypeORM (GitHub).

And, what you see in package.json.

How to install

yarn add @volcanicminds/typeorm

It's possible use this module with module @volcanicminds/backend

How to upgrade packages

yarn upgrade-deps

Postgres (data types)

typeorm postgres: database schema / column types

postgres data types: all postgres data types: numeric

Entities

For example, under /src/entities create the following:

// player.e.ts

import { Entity, Column, Index, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm'

@Entity()
export class Player {
  @PrimaryGeneratedColumn('uuid')
  id: number

  @Index()
  @Column() // default: nullable false
  name: string

  @Column({ type: 'varchar', array: true, nullable: true })
  roles: string[]

  @CreateDateColumn()
  createdAt: Date

  @UpdateDateColumn()
  updatedAt: Date
}

For more info and possibilities see typeorm decorators

Enviroment

# or automatically use LOG_LEVEL
LOG_DB_LEVEL=warn
LOG_COLORIZE=true

Log levels:

  • trace: useful and useless messages, verbose mode
  • debug: well, for debugging purposes.. you know what I mean
  • info: minimal logs necessary for understand that everything is working fine
  • warn: useful warnings if the environment is controlled
  • error: print out errors even if not blocking/fatal errors
  • fatal: ok you are dead now, but you want to know

Query: Operators

It's possible use some operators:

OperatorDescriptionDatatypesExample
nullIs nullallfield:null=true
notNullNot is nullallfield:notNull=true
inIncluded in an arrayallfield:in=A,B,C
ninNot included in an arrayallfield:nin=A,B,C
gtGreater thannumeric, datefield:gt=10
geGreater than or equals tonumeric, datefield:ge=10
ltLess thannumeric, datefield:lt=10
leLess than or equals tonumeric, datefield:le=10
betweenIs between A and Bnumeric, datefield:between=A,B
likeLike with wildcard %textfield:like=va%ue
containsContainstextfield:contains=alu
ncontainsNot containstextfield:ncontains=xyz
startsStarts withtextfield:starts=val
endsEnds withtextfield:ends=lue
eqEquals toallfield:eq=value
neqNot equals toallfield:neq=xyz
likeiLike with wildcard % (ignore-case)textfield:likei=va%ue
containsiContains (ignore-case)textfield:containsi=alu
ncontainsiNot contains (ignore-case)textfield:ncontainsi=xyz
startsiStarts with (ignore-case)textfield:startsi=val
endsiEnds with (ignore-case)textfield:endsi=lue
eqiEquals to (ignore-case)textfield:eqi=value
neqiNot equals to (ignore-case)textfield:neqi=xyz

The expression field=value is equals to field:eq=value

Pay attention: Some datatypes, like UUID, are special types and have possibility to use only specific operator (for example: eq, null, notNull, ..)

Logging

Use Pino logger if in your project you have a global.log with a valid instance.

0.7.0

2 months ago

0.6.2

2 months ago

0.6.1

3 months ago

0.6.0

3 months ago

0.5.1

5 months ago

0.5.0

7 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.4.2

8 months ago

0.2.3

11 months ago

0.2.1

12 months ago

0.1.4

1 year ago

0.2.2

12 months ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.3

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago