mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
44 lines
750 B
TypeScript
44 lines
750 B
TypeScript
import * as moment from 'moment';
|
|
import { BaseModel } from '@/models/Model';
|
|
|
|
export class UserInvite extends BaseModel {
|
|
token!: string;
|
|
userId!: number;
|
|
tenantId!: number;
|
|
email!: string;
|
|
createdAt!: Date;
|
|
|
|
/**
|
|
* Table name.
|
|
*/
|
|
static get tableName() {
|
|
return 'user_invites';
|
|
}
|
|
|
|
/**
|
|
* Timestamps columns.
|
|
*/
|
|
get timestamps() {
|
|
return ['createdAt'];
|
|
}
|
|
|
|
/**
|
|
* Model modifiers.
|
|
*/
|
|
static get modifiers() {
|
|
return {
|
|
notExpired(query) {
|
|
const comp = moment().subtract(24, 'hours').toMySqlDateTime();
|
|
query.where('created_at', '>=', comp);
|
|
},
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Called before inserting a new record.
|
|
*/
|
|
$beforeInsert() {
|
|
this.createdAt = new Date();
|
|
}
|
|
}
|