mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
feat: loading user likes
This commit is contained in:
parent
4c1572a9d8
commit
591dcdf634
@ -28,7 +28,7 @@ export default class MeController extends BaseController {
|
||||
* GET /me
|
||||
*/
|
||||
public async show(ctx: HttpContextContract) {
|
||||
const result = await this.meService.fetchUserContacts(ctx.auth);
|
||||
const result = await this.meService.fetchUserData(ctx.auth);
|
||||
|
||||
if (!result.success && result.error) {
|
||||
throw new Exception(result.message, result.status, result.error.code);
|
||||
|
||||
@ -51,6 +51,11 @@ export default class User extends BaseModel {
|
||||
})
|
||||
public courses: ManyToMany<typeof Course>;
|
||||
|
||||
@manyToMany(() => Course, {
|
||||
pivotTable: 'courses_likes',
|
||||
})
|
||||
public likes: ManyToMany<typeof Course>;
|
||||
|
||||
@column.dateTime({ autoCreate: true, serializeAs: null })
|
||||
public createdAt: DateTime;
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ export default class MeService {
|
||||
* @param auth AuthContract
|
||||
* @returns Response
|
||||
*/
|
||||
public async fetchUserContacts(auth: AuthContract): Promise<IResponse> {
|
||||
public async fetchUserData(auth: AuthContract): Promise<IResponse> {
|
||||
const user = await auth.use(this.authGuard).authenticate();
|
||||
|
||||
await user.load('roles');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user