This commit is contained in:
syuilo 2019-04-13 17:26:38 +09:00
parent 69662e24c3
commit 8c72e011d2
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
1 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import { EntityRepository, Repository } from 'typeorm'; import { EntityRepository, Repository } from 'typeorm';
import { UserList } from '../entities/user-list'; import { UserList } from '../entities/user-list';
import { ensure } from '../../prelude/ensure'; import { ensure } from '../../prelude/ensure';
import { UserListJoinings } from '..';
@EntityRepository(UserList) @EntityRepository(UserList)
export class UserListRepository extends Repository<UserList> { export class UserListRepository extends Repository<UserList> {
@ -9,9 +10,14 @@ export class UserListRepository extends Repository<UserList> {
) { ) {
const userList = typeof src === 'object' ? src : await this.findOne(src).then(ensure); const userList = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
const users = await UserListJoinings.find({
userListId: userList.id
});
return { return {
id: userList.id, id: userList.id,
name: userList.name name: userList.name,
userIds: users.map(x => x.userId)
}; };
} }
} }