also looking at this
UI polish, real queue + scheduling, Bluesky threads, live analytics, blog target
#8
54 files
+2036
-589
| @@ -0,0 +1,65 @@ | ||
| 1 | import { defineModel } from '@stacksjs/orm' | |
| 2 | import { schema } from '@stacksjs/validation' | |
| 3 | ||
| 4 | export default defineModel({ | |
| 5 | name: 'BlogPost', | |
| 6 | table: 'blog_posts', | |
| 7 | primaryKey: 'id', | |
| 8 | autoIncrement: true, | |
| 9 | ||
| 10 | indexes: [ | |
| 11 | { name: 'blog_posts_status_published_at_index', columns: ['status', 'published_at'] }, | |
| 12 | ], | |
| 13 | ||
| 14 | traits: { | |
| 15 | useUuid: true, | |
| 16 | useTimestamps: true, | |
| 17 | useApi: { | |
| 18 | uri: 'blog-posts', | |
| 19 | routes: ['index', 'show'], | |
| 20 | }, | |
| 21 | }, | |
| 22 | ||
| 23 | belongsTo: ['Post', 'Account'], | |
| 24 | ||
| 25 | attributes: { | |
| 26 | title: { | |
| 27 | required: true, | |
| 28 | fillable: true, | |
| 29 | validation: { rule: schema.string().required().max(200) }, | |
| 30 | factory: faker => faker.lorem.sentence({ min: 3, max: 8 }), | |
| 31 | }, | |
| 32 | slug: { | |
| 33 | required: true, | |
| 34 | fillable: true, | |
| 35 | unique: true, | |
| 36 | validation: { rule: schema.string().required().max(220) }, | |
| 37 | factory: faker => faker.lorem.slug(), | |
| 38 | }, | |
| 39 | body: { | |
| 40 | required: true, | |
| 41 | fillable: true, | |
| 42 | validation: { rule: schema.string().required().min(1) }, | |
| 43 | factory: faker => faker.lorem.paragraphs({ min: 2, max: 5 }), | |
| 44 | }, | |
| 45 | excerpt: { | |
| 46 | required: false, | |
| 47 | fillable: true, | |
| 48 | validation: { rule: schema.string().max(500).optional() }, | |
| 49 | factory: faker => faker.lorem.sentences(2), | |
| 50 | }, | |
| 51 | status: { | |
| 52 | required: true, | |
| 53 | fillable: true, | |
| 54 | default: 'draft', | |
| 55 | validation: { rule: schema.enum(['draft', 'published', 'archived']).required() }, | |
| 56 | factory: () => 'published', | |
| 57 | }, | |
| 58 | publishedAt: { | |
| 59 | required: false, | |
| 60 | fillable: true, | |
| 61 | validation: { rule: schema.timestamp().optional() }, | |
| 62 | factory: faker => faker.date.recent({ days: 30 }).toISOString().slice(0, 19).replace('T', ' '), | |
| 63 | }, | |
| 64 | }, | |
| 65 | } as const) | |