Skip to content

Commit 3329d9e

Browse files
committed
updated readme
1 parent 7d30929 commit 3329d9e

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,42 @@ public final class PostRelationsDao {
247247
// more convenience methods
248248
}
249249
```
250-
Instances of RelationDaos are retrieved from the generated database class,
250+
Instances of RelationDaos are retrieved from the generated database class
251+
252+
Snippet of RelationDao usage in main activity
253+
```kotlin
254+
...
255+
// generate 5 posts and each post 4 comments
256+
val posts = IdentifiableList(List.generate(5) {
257+
Post().apply {
258+
uId = ID(it.toString())
259+
title = "post".plus(it)
260+
body = "body".plus(it)
261+
userId = it
262+
comments = List.generate(4) {
263+
PostComment().apply {
264+
name = "nm".repeat(it)
265+
uId = ID((it + 1).toString())
266+
body = "hbytcvbcrxgfvbtrxt"
267+
email = "ejmail;jgfccghcfcvhbhcgvb"
268+
}
269+
}
270+
}
271+
})
272+
273+
// save the posts
274+
postRelationsDao.saveWithComments(posts)
275+
// reading the posts
276+
val posts1 = postRelationsDao.listWithComments()
277+
// display the posts
278+
complex_values_textview.text = posts1.toString()
279+
// delete comments for each post and then delete the post
280+
posts1.forEach {
281+
postRelationsDao.deleteComments(it)
282+
it.delete()
283+
}
284+
...
285+
```
251286

252287

253288
### Database Initialization

0 commit comments

Comments
 (0)