/
doc.go
42 lines (29 loc) · 919 Bytes
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
Package objectbox provides a super-fast, light-weight object persistence framework.
You can define your entity as a standard .go struct, with a comment signalling to generate ObjectBox code
//go:generate go run github.com/objectbox/objectbox-go/cmd/objectbox-gogen
type Person struct {
Id uint64 `objectbox:"id"`
FirstName string
LastName string
}
Now, just init ObjectBox using the generated code (don't forget to errors in your real code,
they are discarded here to keep the example concise)
ob, _ := objectbox.NewBuilder().Model(ObjectBoxModel()).Build()
defer ob.Close()
box := BoxForPerson(ob)
// Create
id, _ := box.Put(&Person{
FirstName: "Joe",
LastName: "Green",
})
// Read
person, _ := box.Get(id)
// Update
person.LastName = "Black"
box.Put(person)
// Delete
box.Remove(person)
To learn more, see https://golang.objectbox.io/
*/
package objectbox