diff --git a/mops.toml b/mops.toml index 550b89f..bbd9166 100644 --- a/mops.toml +++ b/mops.toml @@ -12,8 +12,10 @@ array = "https://github.com/aviate-labs/array.mo#v0.2.0" encoding = "https://github.com/aviate-labs/encoding.mo#v0.3.2" stable-rbtree = "https://github.com/canscale/StableRBTree#v0.6.1" stablebuffer = "https://github.com/skilesare/StableBuffer#v0.2.0" +stablebuffer_1_3_0 = "https://github.com/skilesare/StableBuffer#v2.0" map = "https://github.com/ZhenyaUsenko/motoko-hash-map#v7.0.0" -candy = "https://github.com/icdevs/candy_library#0.3.0" +map9 = "https://github.com/ZhenyaUsenko/motoko-hash-map#v9.0.0" +candy = "https://github.com/icdevs/candy_library#v0.3.0" [dev-dependencies] test = "1.0.1" \ No newline at end of file diff --git a/src/CanDB.mo b/src/CanDB.mo index 4e3f4c6..340d21d 100644 --- a/src/CanDB.mo +++ b/src/CanDB.mo @@ -274,10 +274,16 @@ module { /// See the create() and update() functions in examples/simpleDB/src/main.mo, and the tests in /// updateSuite() in test/HashTreeTest for some examples of how to use CanDB.update() public func update(db: DB, options: UpdateOptions): ?E.Entity { - let ovAttributeMap = RT.update(db.data, options.sk, options.updateAttributeMapFunction); - switch(ovAttributeMap) { + // inefficient solution + let ovAttributeMap = RT.get(db.data, options.sk); + ignore RT.update(db.data, options.sk, options.updateAttributeMapFunction); // Accordingly docs it always returns `?result`, where `result` is the function result. But in practical tests it may return `null`. + let nvAttributeMap = RT.get(db.data, options.sk); + switch(nvAttributeMap) { case null { null }; case (?map) { + if (ovAttributeMap == null) { // TODO: Correct? + db.count += 1; + }; ?{ pk = db.pk; sk = options.sk;