Population
Comments of a post of a user
Imagine the following scenario:
interface Post {
id: number;
userId: number;
title: string;
body: string;
}
interface Comment {
id: number;
postId: number;
userId: number;
body: number;
}
interface User {
id: number;
name: string;
}import { Post, Comment, User } from './interfaces';
@HttpCollection({ name: 'posts' })
@Injectable()
export class PostsState extends CollectionState<Post, Post['id']> { }
@HttpCollection({ name: 'comments' })
@Injectable()
export class CommentsState extends CollectionState<Comment, Comment['id']> { }
@HttpCollection({ name: 'users' })
@Injectable()
export class UsersState extends CollectionState<User, User['id']> { }
@CrudEntities({
name: 'users',
children: [
PostsState,
CommentsState,
UsersState
],
})
@Injectable()
export class EntitiesState extends CrudEntitiesState { }The populate() route instruction
Getting every post's user
Getting one post's comments
Last updated