File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,42 @@ public final class PostRelationsDao {
247
247
// more convenience methods
248
248
}
249
249
```
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
+ ```
251
286
252
287
253
288
### Database Initialization
You can’t perform that action at this time.
0 commit comments