mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-31 11:57:50 +01:00
Add post content
This commit is contained in:
@@ -10,6 +10,7 @@ export default class PostsController {
|
|||||||
public async index ({ response }: HttpContextContract) {
|
public async index ({ response }: HttpContextContract) {
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
posts: await Post.query()
|
posts: await Post.query()
|
||||||
|
.orderBy('id', 'desc')
|
||||||
.preload('tags', (tags) => {
|
.preload('tags', (tags) => {
|
||||||
tags.preload('label')
|
tags.preload('label')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ export default class Post extends BaseModel {
|
|||||||
@column()
|
@column()
|
||||||
public coverId: number
|
public coverId: number
|
||||||
|
|
||||||
|
@belongsTo(() => Translation, {
|
||||||
|
foreignKey: 'contentId'
|
||||||
|
})
|
||||||
|
public content: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public contentId: number
|
||||||
|
|
||||||
@column()
|
@column()
|
||||||
public readingTime: number
|
public readingTime: number
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ export default class Posts extends BaseSchema {
|
|||||||
.unsigned()
|
.unsigned()
|
||||||
.references('files.id')
|
.references('files.id')
|
||||||
.onDelete('CASCADE')
|
.onDelete('CASCADE')
|
||||||
|
table
|
||||||
|
.integer('content_id')
|
||||||
|
.unsigned()
|
||||||
|
.references('translations.id')
|
||||||
|
.onDelete('CASCADE')
|
||||||
table.timestamps(true, true)
|
table.timestamps(true, true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user