Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

DB-context set and delete

  • Loading branch information...
commit 556458ed89880860fa3660c10b4f69b6190c3cc6 1 parent 5c342be
@brendonh authored
View
12 src/loge/database.go
@@ -151,6 +151,18 @@ func (db *LogeDB) DirtyReadLinks(typeName string, linkName string, key LogeKey)
return db.store.getLinks(db.types[typeName], linkName, key)
}
+func (db *LogeDB) SetOne(typeName string, key LogeKey, obj interface{}) {
+ db.Transact(func (t *Transaction) {
+ t.Set(typeName, key, obj)
+ }, 0)
+}
+
+func (db *LogeDB) DeleteOne(typeName string, key LogeKey) {
+ db.Transact(func (t *Transaction) {
+ t.Delete(typeName, key)
+ }, 0)
+}
+
// -----------------------------------------------
// Internals
// -----------------------------------------------
View
4 src/logetest/main.go
@@ -12,9 +12,9 @@ type Pet struct {
}
func main() {
- LinkBench()
+ //LinkBench()
//LinkSandbox()
//WriteBench()
- //Sandbox()
+ Sandbox()
//Example()
}
View
8 src/logetest/sandbox.go
@@ -24,4 +24,12 @@ func Sandbox() {
fmt.Printf("%v\n", trans2.Find("person", "friend", "Mike").All())
fmt.Printf("%v\n", db.Find("person", "friend", "Mike").All())
+
+ db.SetOne("person", "Another", &Person{ "Another", 19, nil })
+
+ fmt.Printf("%v\n", db.DirtyRead("person", "Another"))
+
+ db.DeleteOne("person", "Another")
+
+ fmt.Printf("%v\n", db.DirtyRead("person", "Another"))
}
Please sign in to comment.
Something went wrong with that request. Please try again.