Create belongs_to_one and belongs_to_many inverse helpers
This commit is contained in:
@@ -29,6 +29,10 @@ console.log(sel.clone())
|
||||
const gm = await sel.results().first()
|
||||
|
||||
console.log(gm)
|
||||
console.log(await gm.login_attempts())
|
||||
|
||||
const la = (await gm.login_attempts()).first()
|
||||
console.log(la)
|
||||
|
||||
console.log(await la.user())
|
||||
|
||||
// console.log(await las.fetchRelated())
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import {Model} from '../../orm/src/model/Model.ts'
|
||||
import {Field} from '../../orm/src/model/Field.ts'
|
||||
import {Type} from '../../orm/src/db/types.ts'
|
||||
import UserModel from "./User.model.ts";
|
||||
import {Relation} from "../../orm/src/model/relation/decorators.ts";
|
||||
|
||||
export default class LoginAttemptModel extends Model<LoginAttemptModel> {
|
||||
protected static table = 'daton_login_attempts'
|
||||
@@ -17,4 +19,9 @@ export default class LoginAttemptModel extends Model<LoginAttemptModel> {
|
||||
|
||||
@Field(Type.timestamp)
|
||||
protected attempt_date!: Date
|
||||
|
||||
@Relation()
|
||||
public user() {
|
||||
return this.belongs_to_one(UserModel, 'login_attempts')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user