ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
16
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add user pref model

byarielm.fyi da319979 53457b73

verified
+45 -9
+35 -3
app/models/user_preference.ts
··· 1 - import { UserPreferenceSchema } from '#database/schema' 1 + import { BaseModel, column, belongsTo } from '@adonisjs/lucid/orm' 2 + import type { BelongsTo } from '@adonisjs/lucid/types/relations' 3 + import { DateTime } from 'luxon' 4 + import User from '#models/user' 5 + 6 + export default class UserPreference extends BaseModel { 7 + @column({ isPrimary: true }) 8 + declare id: number 9 + 10 + @column() 11 + declare userDid: string 12 + 13 + @belongsTo(() => User, { foreignKey: 'userDid' }) 14 + declare user: BelongsTo<typeof User> 2 15 3 - export default class UserPreference extends UserPreferenceSchema { 4 - } 16 + @column.dateTime({ autoCreate: true }) 17 + declare createdAt: DateTime 18 + 19 + @column.dateTime({ autoCreate: true, autoUpdate: true }) 20 + declare updatedAt: DateTime 21 + 22 + @column() 23 + declare profileLexicon: string | null 24 + 25 + @column() 26 + declare uploadSources: string[] | null 27 + 28 + @column() 29 + declare followTargets: string[] | null 30 + 31 + @column() 32 + declare consentDataStorage: boolean 33 + 34 + @column() 35 + declare consentNotifications: boolean 36 + }
+1 -4
database/migrations/1761885935168_create_users_table.ts
··· 5 5 6 6 async up() { 7 7 this.schema.createTable(this.tableName, (table) => { 8 - table.increments('id').notNullable() 9 - table.string('full_name').nullable() 10 - table.string('email', 254).notNullable().unique() 11 - table.string('password').notNullable() 8 + table.string('did').primary() 12 9 13 10 table.timestamp('created_at').notNullable() 14 11 table.timestamp('updated_at').nullable()
+9 -2
database/migrations/1773627698421_create_user_preferences_table.ts
··· 5 5 6 6 async up() { 7 7 this.schema.createTable(this.tableName, (table) => { 8 - table.increments('id') 8 + table.increments('id').notNullable() 9 + table.string('user_did').references('did').inTable('users').notNullable() 9 10 10 11 table.timestamp('created_at') 11 12 table.timestamp('updated_at') 13 + 14 + table.string('profile_lexicon') 15 + table.json('upload_sources').nullable() 16 + table.json('follow_targets').nullable() 17 + table.boolean('consent_data_storage').defaultTo(false).notNullable() 18 + table.boolean('consent_notifications').defaultTo(false).notNullable() 12 19 }) 13 20 } 14 21 15 22 async down() { 16 23 this.schema.dropTable(this.tableName) 17 24 } 18 - } 25 + }