mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 22:13:08 +02:00
23 lines
615 B
TypeScript
23 lines
615 B
TypeScript
import { EntityRepository, Repository } from 'typeorm';
|
|
import { UserList } from '../entities/user-list';
|
|
import { ensure } from '../../prelude/ensure';
|
|
import { UserListJoinings } from '..';
|
|
|
|
@EntityRepository(UserList)
|
|
export class UserListRepository extends Repository<UserList> {
|
|
public async pack(
|
|
src: UserList['id'] | UserList,
|
|
) {
|
|
const userList = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
|
|
|
const users = await UserListJoinings.find({
|
|
userListId: userList.id
|
|
});
|
|
|
|
return {
|
|
id: userList.id,
|
|
name: userList.name,
|
|
userIds: users.map(x => x.userId)
|
|
};
|
|
}
|
|
}
|