Skip to content

Commit

Permalink
revert back selection criteria with options
Browse files Browse the repository at this point in the history
  • Loading branch information
douggynix committed Jul 6, 2024
1 parent fb3b6d2 commit d849519
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
use crate::CollectionConfig;
use mongodb::bson::{doc, from_bson, Bson, Document};
use mongodb::options::ReadPreference;
use mongodb::options::{RunCommandOptions, SelectionCriteria};
use mongodb::Database;
use serde::Deserialize;
use std::borrow::Cow;
Expand Down Expand Up @@ -502,11 +504,13 @@ async fn h_run_command(
db: &Database,
command_doc: Document,
) -> Result<Document, mongodb::error::Error> {
let primary_options = RunCommandOptions::builder()
.selection_criteria(SelectionCriteria::ReadPreference(ReadPreference::Primary))
.build();

let ret = db
.run_command(
command_doc,
//Some(SelectionCriteria::ReadPreference(ReadPreference::Primary)),
)
.run_command(command_doc)
.with_options(primary_options)
.await?;
if let Ok(err) = from_bson::<mongodb::error::CommandError>(Bson::Document(ret.clone())) {
Err(mongodb::error::Error::from(
Expand Down

0 comments on commit d849519

Please sign in to comment.