I am trying to use the google-datastore1_beta3 crate to do some basic CRUD operations. There aren't many examples, but the docs seemed simple enough. I could get operations working and it retrieves entities. But trying to use an upsert or insert operation results in a 400 Bad Request error. The code is:
pub fn upsert(&self, entity: Entity) -> std::result::Result<Option<Key>, Error> {
let req = CommitRequest {
transaction: None,
mutations: Some(vec![
Mutation {
insert: None,
delete: None,
update: None,
base_version: None,
upsert: Some(entity)
}
]),
mode: Some("NON_TRANSACTIONAL".to_string())
};
println!("{:?}", req);
let result = self.ds.projects().commit(req, &self.project).doit();
match result {
Ok((_, commit_response)) => {
if let Some(mut_results) = commit_response.mutation_results {
match mut_results.first() {
Some(mr) => Ok(mr.key.clone()),
None => Ok(None)
}
} else {
Ok(None)
}
},
Err(e) => {
Err(e)
},
}
}
I've also made a small repo to reproduce the issue, please see: https://github.com/n-k/dstest/blob/master/src/db.rs#L32
Has anyone had success with using this crate?