You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then copy the downloaded `lib/objectbox.dll` to `C:\Windows\System32\` (requires admin privileges).
55
47
@@ -59,52 +51,28 @@ After you've defined your persisted entities (see below), run `pub run build_run
59
51
Getting started
60
52
----------------
61
53
In general, Dart class annotations are used to mark classes as ObjectBox entities and provide meta information.
62
-
Note that right now, only a limited set of types is supported; this will be expanded upon in the near future.
63
54
Entity IDs and UIDs that are defined in their respective annotations need to be unique across all entities, while
64
55
property IDs only need to be unique in their respective entity; property UIDs also need to be globally unique.
65
56
66
-
### Object IDs
67
-
68
-
Each entity is required to have an _Id_ property of type _Long_.
57
+
Each entity is required to have an ID property of type `int`.
69
58
Already persisted entities have an ID greater or equal to 1.
70
-
New (not yet persisted) objects typically have _Id_ value of `0` or `null`: calling `Box.put` automatically assigns a new ID to the object.
59
+
New (not yet persisted) objects typically have ID value of `0` or `null`: calling `Box.put` automatically assigns a new ID to the object.
71
60
72
61
### Example
62
+
For a code example, see [example/README.md](example/README.md)
73
63
64
+
### Box
65
+
Box is your main interface for storing and retrieving data.
74
66
```dart
75
-
import "package:objectbox/objectbox.dart";
76
-
part "note.g.dart";
77
-
78
-
@Entity()
79
-
class Note {
80
-
@Id() // automatically always 'int' in Dart code and 'Long' in ObjectBox
81
-
int id;
82
-
83
-
String text;
84
-
85
-
Note(); // empty default constructor needed
86
-
Note.construct(this.text);
87
-
toString() => "Note{id: $id, text: $text}";
88
-
}
89
-
```
90
-
91
-
In your main function, you can then create a _store_ which needs an array of your entity classes and definitions to be constructed. If you have several entities, construct your store like `Store([[Entity1, Entity1_OBXDefs], [Entity2, Entity2_OBXDefs]])` etc.
92
-
Finally, you need a _box_, representing the interface for objects of one specific entity type.
93
-
94
-
```dart
95
-
var store = Store([Note_OBXDefs]);
96
67
var box = Box<Note>(store);
97
-
98
-
var note = Note.construct("Hello");
68
+
69
+
var note = Note(text: "Hello");
99
70
note.id = box.put(note);
100
71
print("new note got id ${note.id}");
101
72
print("refetched note: ${box.get(note.id)}");
102
-
103
-
store.close();
104
73
```
105
74
106
75
### Query and QueryBuilder
107
-
108
76
Basic querying can be done with e.g.:
109
77
110
78
```dart
@@ -137,7 +105,6 @@ box.query(overloaded as Condition).build(); // the cast is necessary due to the
137
105
```
138
106
139
107
### Ordering
140
-
141
108
The results from a query can be ordered using the `order` method, e.g.
0 commit comments