Last active
January 17, 2020 10:23
-
-
Save umutyerebakmaz/bdeed4382a33cef609d8b9efe89af933 to your computer and use it in GitHub Desktop.
TypeORM ManyToMany Kullanımı.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Resolver, Mutation, Arg } from 'type-graphql'; | |
import { User } from './user.entity'; | |
import { UserAuthorLike } from '../user-author-like/user-author-like.entity'; | |
@Resolver(User) | |
export class UserResolver { | |
// yazar beğen | |
@Mutation(() => Boolean) | |
async yazarBegen( | |
@Arg('userId') userId: string, | |
@Arg('authorId') authorId: string | |
): Promise<Boolean> { | |
await UserAuthorLike.create({ userId, authorId }).save(); | |
return true; | |
}; | |
// yazar beğenme | |
@Mutation(() => Boolean) | |
async yazarBegenme( | |
@Arg('userId') userId: string, | |
@Arg('authorId') authorId: string | |
): Promise<Boolean> { | |
await UserAuthorLike.delete({ userId, authorId }); | |
return true; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment