Skip to content

Instantly share code, notes, and snippets.

@umutyerebakmaz
Created January 20, 2020 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umutyerebakmaz/f551edf954a40021a735039065538d06 to your computer and use it in GitHub Desktop.
Save umutyerebakmaz/f551edf954a40021a735039065538d06 to your computer and use it in GitHub Desktop.
TypeORM ManyToMany Örnek
import { Resolver, Authorized, Mutation, Arg } from 'type-graphql';
import { UserAuthorLike } from './user-author-like.entity';
@Resolver()
export class UserAuthorLikeResolver {
@Authorized('ADMIN', 'MODERATOR', 'MEMBER')
@Mutation(() => Boolean)
async yazarBegen(
@Arg('userId') userId: string,
@Arg('authorId') authorId: string
): Promise<Boolean> {
await UserAuthorLike.create({ userId, authorId }).save();
return true;
};
@Authorized('ADMIN', 'MODERATOR', 'MEMBER')
@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