Initial commit
This commit is contained in:
24
app/models/LoginAttempt.model.ts
Normal file
24
app/models/LoginAttempt.model.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Model, Type, Field, Relation } from '../../bundle/daton_orm.ts'
|
||||
import User from "./User.model.ts";
|
||||
|
||||
export default class LoginAttempt extends Model<LoginAttempt> {
|
||||
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
|
||||
|
||||
@Relation()
|
||||
public user() {
|
||||
return this.belongs_to_one(User, 'login_attempts')
|
||||
}
|
||||
}
|
||||
27
app/models/User.model.ts
Normal file
27
app/models/User.model.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Model, Type, Field, Relation } from '../../bundle/daton_orm.ts'
|
||||
import LoginAttemptModel from './LoginAttempt.model.ts'
|
||||
|
||||
export default class User extends Model<User> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
19
app/models/http/Session.model.ts
Normal file
19
app/models/http/Session.model.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { SessionModel } from '../../../bundle/daton.ts'
|
||||
import { Field, Type } from '../../../bundle/daton_orm.ts'
|
||||
|
||||
export default class Session extends SessionModel {
|
||||
protected static table = 'sessions'
|
||||
protected static key = 'session_key'
|
||||
|
||||
protected static readonly CREATED_AT = 'start_time'
|
||||
protected static readonly UPDATED_AT = null // No updated at
|
||||
|
||||
@Field(Type.varchar)
|
||||
protected session_key!: string
|
||||
|
||||
@Field(Type.int)
|
||||
protected user_id?: number
|
||||
|
||||
@Field(Type.timestamp)
|
||||
protected start_time!: Date
|
||||
}
|
||||
Reference in New Issue
Block a user