Support serializing directly to Document

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Fixed
    • Priority: Major - P3
    • bson-1.1.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, if a user wishes to insert an instance of their struct, they must first convert it to bson and then either use as_document + clone, unwrap it manually via a match statement, or use both to_bson and from_bson. These are all quite verbose and could be shortened if it were possible to serialize something directly to Document.

      coll.insert_one(bson::to_document(post)?, None).await?
      // vs
      coll.insert_one(bson::from_bson(bson::to_bson(post)?)?, None).await?
      

      See discussion on GitHub: https://github.com/mongodb/bson-rust/issues/128

              Assignee:
              Isabel Atkinson
              Reporter:
              Patrick Freed
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: