skip to Main Content

I have this code here:

pub struct Account {
    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
    pub id: Option<ObjectId>,
    pub email: String,
}

And I want to change "ObjectId" to String so I can use Ulid.

2

Answers


  1. If you need String use

    let str_id: String = account.id.unwrap().to_hex();  
    
    Login or Signup to reply.
  2. check this it worked for me using MongoDB crate but you can give it a try Solution

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search