mongo_archive

Crates.iomongo_archive
lib.rsmongo_archive
version0.1.0
sourcesrc
created_at2024-05-31 07:34:14.302752
updated_at2024-05-31 07:34:14.302752
descriptionA parser for MongoDB archive.
homepage
repositoryhttps://github.com/zerodegress/mongo_archive
max_upload_size
id1257750
size11,472
ZeroDegress (zerodegress)

documentation

README

mongo_archive

A parser for MongoDB archive.

Example

use std::{
    fs::OpenOptions,
    io::{BufWriter, Cursor},
};

use mongo_archive::MongoArchive;

fn main() -> anyhow::Result<()> {
    // read and parse as bson::Bson
    let docs = MongoArchive::from_reader(Cursor::new(include_bytes!("./createshiprecords"))).parse();
    let json_value: serde_json::Value = bson::from_bson(docs)?;
    let out = OpenOptions::new()
        .create(true)
        .truncate(true)
        .write(true)
        .read(false)
        .open("createshiprecords.json")?;
    let buf_writer = BufWriter::new(out);
    serde_json::to_writer(buf_writer, &json_value)?;
    Ok(())
}
Commit count: 1

cargo fmt