mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
chore: create user, collection and link models, migrations and seeders
This commit is contained in:
@@ -1,5 +1,29 @@
|
||||
import { BaseModel, CamelCaseNamingStrategy } from '@adonisjs/lucid/orm';
|
||||
import { BaseModel, CamelCaseNamingStrategy, beforeCreate, column } from '@adonisjs/lucid/orm';
|
||||
import { DateTime } from 'luxon';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
export default class AppBaseModel extends BaseModel {
|
||||
static namingStrategy = new CamelCaseNamingStrategy();
|
||||
static selfAssignPrimaryKey = true;
|
||||
|
||||
@column({ isPrimary: true })
|
||||
declare id: string; // UUID
|
||||
|
||||
@column.dateTime({
|
||||
autoCreate: true,
|
||||
serializeAs: 'createdAt',
|
||||
})
|
||||
declare createdAt: DateTime;
|
||||
|
||||
@column.dateTime({
|
||||
autoCreate: true,
|
||||
autoUpdate: true,
|
||||
serializeAs: 'updatedAt',
|
||||
})
|
||||
declare updatedAt: DateTime;
|
||||
|
||||
@beforeCreate()
|
||||
static assignUuid(item: any) {
|
||||
item.id = uuidv4();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user