add getPostsIds methodfor ReadPostsAPI
This commit is contained in:
parent
6b36cd7390
commit
35c2de527b
@ -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]
|
||||||
*/
|
*/
|
||||||
|
@ -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 }
|
||||||
|
Loading…
Reference in New Issue
Block a user