Note: You should consider when to use ancestor/key design with care. You'll get a limit of 1 write/sec for each entity group.
First, map your entity endpoints:
@Endpoint(path = "/users")
public class User {
@Id
IdRef<User> id;
// other fields
}
@Endpoint(path = "/posts")
public class Post {
@Id
private IdRef<Post> id;
@ParentId
IdRef<User> userId;
// other fields
}
@Endpoint(path = "/comments")
public class Comment {
@Id
IdRef<Comment> id;
@ParentId
IdRef<Post> postId;
// other fields
}
Then, an example on how to create an action for a given comment:
public class CommentLikeAction extends Action<Comment> {
@PUT
public void like(IdRef<Comment> id) {
Comment comment = id.fetch();
comment.like();
yawp.save(comment);
}
}
This will create the following HTTP API:
PUT /users/{userId}/posts/{postId}/comments/{commentId}/like
Or, from the YAWP!'s Javascript client you may call:
yawp('/users/{userId}/posts/{postId}/comments/{commentId}').put('like').done( function() {} )