|
| 1 | +import type { Model } from '@stacksjs/types' |
| 2 | +import { schema } from '@stacksjs/validation' |
| 3 | + |
| 4 | +export default { |
| 5 | + name: 'JudgeReview', |
| 6 | + table: 'judge_reviews', |
| 7 | + primaryKey: 'id', |
| 8 | + autoIncrement: true, |
| 9 | + |
| 10 | + indexes: [ |
| 11 | + { |
| 12 | + name: 'judge_reviews_title_index', |
| 13 | + columns: ['title'], |
| 14 | + }, |
| 15 | + ], |
| 16 | + |
| 17 | + traits: { |
| 18 | + useUuid: true, |
| 19 | + useTimestamps: true, |
| 20 | + useSearch: { |
| 21 | + displayable: ['id', 'title', 'content', 'rating'], |
| 22 | + searchable: ['title', 'content'], |
| 23 | + sortable: ['created_at', 'updated_at', 'rating'], |
| 24 | + filterable: ['rating', 'status', 'type'], |
| 25 | + }, |
| 26 | + |
| 27 | + useSeeder: { |
| 28 | + count: 10, |
| 29 | + }, |
| 30 | + |
| 31 | + useApi: { |
| 32 | + uri: 'judge-reviews', |
| 33 | + routes: ['index', 'store', 'show'], |
| 34 | + }, |
| 35 | + |
| 36 | + observe: true, |
| 37 | + }, |
| 38 | + |
| 39 | + belongsTo: ['Judge', 'User'], |
| 40 | + |
| 41 | + attributes: { |
| 42 | + title: { |
| 43 | + required: true, |
| 44 | + order: 1, |
| 45 | + fillable: true, |
| 46 | + validation: { |
| 47 | + rule: schema.string().min(3).max(255), |
| 48 | + message: { |
| 49 | + min: 'Title must have a minimum of 3 characters', |
| 50 | + max: 'Title must have a maximum of 255 characters', |
| 51 | + }, |
| 52 | + }, |
| 53 | + factory: faker => faker.lorem.sentence(), |
| 54 | + }, |
| 55 | + |
| 56 | + content: { |
| 57 | + required: true, |
| 58 | + order: 2, |
| 59 | + fillable: true, |
| 60 | + validation: { |
| 61 | + rule: schema.string().min(10).max(1000), |
| 62 | + message: { |
| 63 | + min: 'Content must have a minimum of 10 characters', |
| 64 | + max: 'Content must have a maximum of 1000 characters', |
| 65 | + }, |
| 66 | + }, |
| 67 | + factory: faker => faker.lorem.paragraphs(2), |
| 68 | + }, |
| 69 | + |
| 70 | + rating: { |
| 71 | + required: true, |
| 72 | + order: 3, |
| 73 | + fillable: true, |
| 74 | + validation: { |
| 75 | + rule: schema.number().min(1).max(5), |
| 76 | + message: { |
| 77 | + min: 'Rating must be at least 1', |
| 78 | + max: 'Rating cannot exceed 5', |
| 79 | + }, |
| 80 | + }, |
| 81 | + factory: faker => faker.number.int({ min: 1, max: 5 }), |
| 82 | + }, |
| 83 | + |
| 84 | + likes: { |
| 85 | + required: true, |
| 86 | + order: 4, |
| 87 | + fillable: true, |
| 88 | + validation: { |
| 89 | + rule: schema.number().min(0), |
| 90 | + message: { |
| 91 | + min: 'Likes cannot be negative', |
| 92 | + }, |
| 93 | + }, |
| 94 | + factory: faker => faker.number.int({ min: 0, max: 100 }), |
| 95 | + }, |
| 96 | + |
| 97 | + comments: { |
| 98 | + required: true, |
| 99 | + order: 5, |
| 100 | + fillable: true, |
| 101 | + validation: { |
| 102 | + rule: schema.number().min(0), |
| 103 | + message: { |
| 104 | + min: 'Comments cannot be negative', |
| 105 | + }, |
| 106 | + }, |
| 107 | + factory: faker => faker.number.int({ min: 0, max: 50 }), |
| 108 | + }, |
| 109 | + |
| 110 | + type: { |
| 111 | + required: true, |
| 112 | + order: 6, |
| 113 | + fillable: true, |
| 114 | + validation: { |
| 115 | + rule: schema.string(), |
| 116 | + message: { |
| 117 | + required: 'Type is required', |
| 118 | + }, |
| 119 | + }, |
| 120 | + factory: faker => faker.helpers.arrayElement(['positive', 'negative', 'neutral']), |
| 121 | + }, |
| 122 | + |
| 123 | + status: { |
| 124 | + required: true, |
| 125 | + order: 7, |
| 126 | + fillable: true, |
| 127 | + validation: { |
| 128 | + rule: schema.string(), |
| 129 | + message: { |
| 130 | + required: 'Status is required', |
| 131 | + }, |
| 132 | + }, |
| 133 | + factory: faker => faker.helpers.arrayElement(['published', 'pending', 'rejected']), |
| 134 | + }, |
| 135 | + }, |
| 136 | + |
| 137 | + dashboard: { |
| 138 | + highlight: true, |
| 139 | + }, |
| 140 | +} satisfies Model |
0 commit comments