Skip to content

Commit b0de1f1

Browse files
Add all types to README.
1 parent 0a5b42b commit b0de1f1

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,19 @@ from objectbox.model import *
4141
@Entity(id=1, uid=1)
4242
class Person:
4343
id = Id(id=1, uid=1001)
44-
first_name = Property(str, id=2, uid=1002)
45-
last_name = Property(str, id=3, uid=1003)
44+
name = Property(str, id=2, uid=1002)
45+
is_enabled = Property(bool, id=3, uid=1003)
46+
# int can be stored with 64 (default), 32, 16 or 8 bit precision.
47+
int64 = Property(int, id=4, uid=1004)
48+
int32 = Property(int, type=PropertyType.int, id=5, uid=1005)
49+
int16 = Property(int, type=PropertyType.short, id=6, uid=1006)
50+
int8 = Property(int, type=PropertyType.byte, id=7, uid=1007)
51+
# float can be stored with 64 or 32 (default) bit precision.
52+
float64 = Property(float, id=8, uid=1008)
53+
float32 = Property(float, type=PropertyType.float, id=9, uid=1009)
54+
byte_array = Property(bytes, id=10, uid=1010)
55+
# Regular properties are not stored.
56+
transient = ""
4657
```
4758

4859
### Using ObjectBox
@@ -58,16 +69,16 @@ import objectbox
5869

5970
# Configure ObjectBox: should be done only once in the whole program and the "ob" variable should be kept around
6071
model = objectbox.Model()
61-
model.entity(Person, last_property_id=objectbox.model.IdUid(3, 1003))
72+
model.entity(Person, last_property_id=objectbox.model.IdUid(10, 1010))
6273
model.last_entity_id = objectbox.model.IdUid(1, 1)
6374
ob = objectbox.Builder().model(model).directory("db").build()
6475

6576
# Open the box of "Person" entity. This can be called many times but you can also pass the variable around
6677
box = objectbox.Box(ob, Person)
6778

68-
id = box.put(Person(first_name="Joe", last_name="Green")) # Create
79+
id = box.put(Person(name="Joe Green")) # Create
6980
person = box.get(id) # Read
70-
person.last_name = "Black"
81+
person.name = "Joe Black"
7182
box.put(person) # Update
7283
box.remove(person) # Delete
7384
```

0 commit comments

Comments
 (0)