start relations (has one or many; has one; has many)
This commit is contained in:
20
app/models/LoginAttempt.model.ts
Normal file
20
app/models/LoginAttempt.model.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {Model} from '../../orm/src/model/Model.ts'
|
||||
import {Field} from '../../orm/src/model/Field.ts'
|
||||
import {Type} from '../../orm/src/db/types.ts'
|
||||
|
||||
export default class LoginAttemptModel extends Model<LoginAttemptModel> {
|
||||
protected static table = 'daton_login_attempts'
|
||||
protected static key = 'daton_login_attempt_id'
|
||||
|
||||
protected static readonly CREATED_AT = 'attempt_date'
|
||||
protected static readonly UPDATED_AT = null
|
||||
|
||||
@Field(Type.int)
|
||||
protected daton_login_attempt_id?: number
|
||||
|
||||
@Field(Type.int)
|
||||
protected user_id!: number
|
||||
|
||||
@Field(Type.timestamp)
|
||||
protected attempt_date!: Date
|
||||
}
|
||||
30
app/models/User.model.ts
Normal file
30
app/models/User.model.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import {Model} from '../../orm/src/model/Model.ts'
|
||||
import {Type} from '../../orm/src/db/types.ts'
|
||||
import {Field} from '../../orm/src/model/Field.ts'
|
||||
import LoginAttemptModel from './LoginAttempt.model.ts'
|
||||
import {Relation} from '../../orm/src/model/relation/decorators.ts'
|
||||
|
||||
export default class UserModel extends Model<UserModel> {
|
||||
protected static table = 'daton_users'
|
||||
protected static key = 'user_id'
|
||||
|
||||
protected static readonly CREATED_AT = 'created_at'
|
||||
protected static readonly UPDATED_AT = 'updated_at'
|
||||
|
||||
@Field(Type.int)
|
||||
protected user_id?: number
|
||||
|
||||
@Field(Type.varchar)
|
||||
protected first_name!: String
|
||||
|
||||
@Field(Type.varchar)
|
||||
protected last_name!: String
|
||||
|
||||
@Field(Type.bool)
|
||||
protected active!: Boolean
|
||||
|
||||
@Relation()
|
||||
public login_attempts() {
|
||||
return this.has_many(LoginAttemptModel)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user