add getPostsIds methodfor ReadPostsAPI

This commit is contained in:
InsanusMokrassar 2019-11-11 09:21:23 +06:00
parent 6b36cd7390
commit 35c2de527b
2 changed files with 6 additions and 1 deletions

View File

@ -13,6 +13,11 @@ import com.soywiz.klock.DateTime
* Simple read API by different properties * Simple read API by different properties
*/ */
interface ReadPostsAPI { interface ReadPostsAPI {
/**
* @return [Set] of [PostId]s which can be used to get data using [getPostById]
*/
suspend fun getPostsIds(): Set<PostId>
/** /**
* @return [RegisteredPost] if it is available by [id] * @return [RegisteredPost] if it is available by [id]
*/ */

View File

@ -63,7 +63,7 @@ class InMemoryPostsAPI(
} != null } != null
} }
override suspend fun getPostsIds(): Set<PostId> = posts.keys.toSet()
override suspend fun getPostById(id: PostId): RegisteredPost? = posts[id] override suspend fun getPostById(id: PostId): RegisteredPost? = posts[id]
override suspend fun getPostsByContent(id: ContentId): List<RegisteredPost> = override suspend fun getPostsByContent(id: ContentId): List<RegisteredPost> =
posts.values.filter { post -> id in post.content } posts.values.filter { post -> id in post.content }