Skip to content

Commit a02bdbb

Browse files
authored
Merge pull request #5 from AIBlockOfficial/v0.1.4
Bugfix for data fetch in MongoDB; Bump to v0.1.4
2 parents e1e7335 + 8ddc530 commit a02bdbb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "valence_core"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
edition = "2021"
55
license = "MIT"
66
keywords = ["blockchain", "L2", "peer-to-peer", "P2P"]

src/db/mongo_db.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ impl KvStoreConnection for MongoDbConn {
9191
let existing_doc = collection.find_one(filter.clone(), None).await?;
9292

9393
let mut vec: Vec<T> = if let Some(doc) = existing_doc {
94-
// Deserialize the existing data
95-
mongodb::bson::from_bson(doc.get("data").unwrap().clone())?
94+
if doc.contains_key("data") {
95+
// Deserialize the existing data
96+
mongodb::bson::from_bson(doc.get("data").unwrap().clone())?
97+
} else {
98+
Vec::new()
99+
}
96100
} else {
97101
Vec::new()
98102
};

0 commit comments

Comments
 (0)