Skip to content

Instantly share code, notes, and snippets.

@nesterone
Last active January 21, 2020 09:32
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 nesterone/d3596c8c5d1cecb6bedc763c84975243 to your computer and use it in GitHub Desktop.
Save nesterone/d3596c8c5d1cecb6bedc763c84975243 to your computer and use it in GitHub Desktop.
export class CreatePostCommand extends Command {
/**
* Creates a command for adding new post to the system,
* @param {Posts} posts - posts in system
*/
constructor(posts) {
super();
this.posts = posts;
}
/**
* Creates new post in system
* @param {Post} post - new post not yet added to system
* @param {string} id - id of newly created post
*/
async execute(post) {
post = await this.posts.add(post);
return post.id();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment