app/Models/Order.ts   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 37
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 33
mnd 1
bc 1
fnc 0
dl 0
loc 37
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
rs 10
1
import { DateTime } from 'luxon'
2
import { BaseModel, column, belongsTo, BelongsTo } from '@ioc:Adonis/Lucid/Orm'
3
import Merchant from 'App/Models/Merchant'
4
import Product from 'App/Models/Product'
5
6
export default class Order extends BaseModel {
7
  @column({ isPrimary: true })
8
  public id: number
9
10
  @column()
11
  public userId: number
12
13
  @column()
14
  public productId: number
15
16
  @column()
17
  public quantity: number
18
19
  @column({ serialize: (value: number) => {
20
      return value === 1 ? true : false
21
    }
22
  })
23
  public isSuccessful: number | boolean
24
25
  @column.dateTime({ autoCreate: true })
26
  public createdAt: DateTime
27
28
  @column.dateTime({ autoCreate: true, autoUpdate: true })
29
  public updatedAt: DateTime
30
31
  @belongsTo(() => Product)
32
  public product: BelongsTo<typeof Product>
33
34
  @belongsTo(() => Merchant)
35
  public merchant: BelongsTo<typeof Merchant>
36
}
37