I am newbie to rust... i am trying to access document from couchdb using the sofa crate; code at the end
When i print the document result.. i get the following result. How do i access the "packet' field in the object?
I tired documents["packet"] and that did not work. Any suggestions?
DocumentCollection { offset: 0, rows: [DocumentCollectionItem { id: "c15a79c86472797b78f4e540ea00e24b", doc: Document { _id: "c15a79c86472797b78f4e540ea00e24b", _rev: "5-b51fff00e06e0b39e1fbb77d5f27c6d1", doc: Object({"_id": String("c15a79c86472797b78f4e540ea00e24b"), "_rev": String("5-b51fff00e06e0b39e1fbb77d5f27c6d1"), "description": String("alpha"), "packet": Number(5432), "version": Number(2)}) } }], total_rows: 1 }
[Object({"_id": String("c15a79c86472797b78f4e540ea00e24b"), "_rev": String("5-b51fff00e06e0b39e1fbb77d5f27c6d1"), "description": String("alpha"), "packet": Number(5432), "version": Number(2)})]
let client = Client::new("http://v10-lv2p20397:5984".into()).unwrap();
let dbw = client.db("log_packet");
assert!(dbw.is_ok());
let db = dbw.unwrap();
let documents_res = db.find(json!({
"selector": {
"packet": 5432,
"version": 2
},
"limit": 1
}));
assert!(documents_res.is_ok());
let documents = documents_res.unwrap();
println!("{:?}", documents);
println!("{:?}", documents.get_data());