Skip to content

Commit

Permalink
feat: change to_bson calls to add serializer options human readable
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen committed Oct 20, 2023
1 parent 207f402 commit 7ac2844
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
13 changes: 11 additions & 2 deletions rs/packages/db/src/models/media_session/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use crate::Model;
use mongodb::{bson::doc, options::FindOneOptions, results::UpdateResult, IndexModel};
use mongodb::{
bson::{doc, SerializerOptions},
options::FindOneOptions,
results::UpdateResult,
IndexModel,
};
use serde::{Deserialize, Serialize};
use serde_util::DateTime;
use ts_rs::TS;
Expand Down Expand Up @@ -83,7 +88,11 @@ pub struct MediaSessionNowPlaying {

impl From<MediaSessionNowPlaying> for mongodb::bson::Bson {
fn from(value: MediaSessionNowPlaying) -> Self {
mongodb::bson::to_bson(&value).expect("error convering MediaSessionNowPlaying to Bson")
mongodb::bson::to_bson_with_options(
&value,
SerializerOptions::builder().human_readable(false).build(),
)
.expect("error convering MediaSessionNowPlaying to Bson")
}
}

Expand Down
8 changes: 6 additions & 2 deletions rs/packages/db/src/models/station/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use constants::validate::*;
use drop_tracer::Token;
use geoip::CountryCode;
use lang::LangCode;
use mongodb::bson::{doc, Bson};
use mongodb::bson::{doc, Bson, SerializerOptions};
use mongodb::options::{FindOneAndUpdateOptions, ReturnDocument};
use mongodb::{ClientSession, IndexModel};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -332,7 +332,11 @@ pub struct OwnerDeploymentInfo {

impl From<OwnerDeploymentInfo> for Bson {
fn from(info: OwnerDeploymentInfo) -> Bson {
mongodb::bson::to_bson(&info).unwrap()
mongodb::bson::to_bson_with_options(
&info,
SerializerOptions::builder().human_readable(false).build(),
)
.unwrap()
}
}

Expand Down
8 changes: 6 additions & 2 deletions rs/packages/db/src/models/station_picture_variant/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{storage_db, Model};
use bytes::Bytes;
use mongodb::bson::doc;
use mongodb::bson::{doc, SerializerOptions};
use mongodb::options::IndexOptions;
use mongodb::IndexModel;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -58,6 +58,10 @@ pub enum StationPictureVariantFormat {

impl From<StationPictureVariantFormat> for mongodb::bson::Bson {
fn from(value: StationPictureVariantFormat) -> Self {
mongodb::bson::to_bson(&value).unwrap()
mongodb::bson::to_bson_with_options(
&value,
SerializerOptions::builder().human_readable(false).build(),
)
.unwrap()
}
}

0 comments on commit 7ac2844

Please sign in to comment.