6
6
[ ObjectBox] ( https://objectbox.io/ ) is a superfast object-oriented database with strong relation support.
7
7
ObjectBox is embedded into your Android, Linux, macOS, or Windows app.
8
8
9
- ** Latest version: [ 2.9.1 (2021/03/15 )] ( https://docs.objectbox.io/#objectbox-changelog ) **
9
+ ** Latest version: [ 3.0.0 (2021/10/19 )] ( https://docs.objectbox.io/#objectbox-changelog ) **
10
10
11
11
Demo code using ObjectBox:
12
12
13
+ ``` kotlin
14
+ // Kotlin
15
+ val playlist = Playlist (" My Favorites" )
16
+ playlist.songs.add(Song (" Lalala" ))
17
+ playlist.songs.add(Song (" Lololo" ))
18
+ box.put(playlist)
19
+ ```
20
+
13
21
``` java
22
+ // Java
14
23
Playlist playlist = new Playlist (" My Favorites" );
15
24
playlist. songs. add(new Song (" Lalala" ));
16
25
playlist. songs. add(new Song (" Lololo" ));
@@ -29,27 +38,40 @@ Besides JVM based languages like Java and Kotlin, ObjectBox also offers:
29
38
30
39
Gradle setup
31
40
------------
32
- Add this to your root build.gradle (project level) :
41
+ For Android projects, add the ObjectBox Gradle plugin to your root ` build.gradle ` :
33
42
34
43
``` groovy
35
44
buildscript {
36
- ext.objectboxVersion = '2.9.1'
45
+ ext.objectboxVersion = "3.0.0"
46
+ repositories {
47
+ mavenCentral()
48
+ }
37
49
dependencies {
38
- classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
50
+ classpath( "io.objectbox:objectbox-gradle-plugin:$objectboxVersion")
39
51
}
40
52
}
41
53
```
42
54
43
- And this to our app's build.gradle (module level) :
55
+ And in your app's ` build.gradle ` apply the plugin :
44
56
45
57
``` groovy
46
- apply plugin: 'io.objectbox' // after applying Android plugin
58
+ // Using plugins syntax:
59
+ plugins {
60
+ id("io.objectbox") // Add after other plugins.
61
+ }
62
+
63
+ // Or using the old apply syntax:
64
+ apply plugin: "io.objectbox" // Add after other plugins.
47
65
```
48
66
49
67
First steps
50
68
-----------
51
- Create data object class ` @Entity ` , for example "Playlist".
52
- ``` java
69
+ Create a data object class ` @Entity ` , for example "Playlist".
70
+ ```
71
+ // Kotlin
72
+ @Entity data class Playlist( ... )
73
+
74
+ // Java
53
75
@Entity public class Playlist { ... }
54
76
```
55
77
Now build the project to let ObjectBox generate the class ` MyObjectBox ` for you.
0 commit comments