Know when the store is new

18 views
Skip to first unread message

jo...@mm.st

unread,
Dec 26, 2015, 6:14:35 AM12/26/15
to gosh...@googlegroups.com
How to know if the store has not data?

result, _, err := conn.RunTransaction(func(txn *client.Txn)
(interface{}, error) {
rootObj, err := txn.GetRootObject()
if err != nil {
return nil, err
}

objs, err := rootObj.References()
if err != nil {
return nil, err
}
lf len(objs) == 0 {
println("new database")
}
})

Matthew Sackman

unread,
Dec 26, 2015, 7:44:10 AM12/26/15
to gosh...@googlegroups.com
Objects can only be reached through navigation from the root object. So
yes, if the root object has no references then the root object can be
treated as the only object in the database.

Hope that helps,

Matthew
Reply all
Reply to author
Forward
0 new messages