Skip to content

Instantly share code, notes, and snippets.

@umutyerebakmaz
Last active January 17, 2020 10:23
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/bdeed4382a33cef609d8b9efe89af933 to your computer and use it in GitHub Desktop.
Save umutyerebakmaz/bdeed4382a33cef609d8b9efe89af933 to your computer and use it in GitHub Desktop.
TypeORM ManyToMany Kullanımı.
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