0.1.10 • Published 5 years ago

mongodb-schema-parser v0.1.10

Weekly downloads
9
License
Apache-2.0
Repository
github
Last release
5 years ago

mongodb-schema-parser

crates.io version build status downloads docs.rs docs

Infer a probabilistic schema for a MongoDB collection. This library is meant to be used in Rust or as Web Assembly module in JavaScript.

Usage: in Rust

use SchemaParser

pub fn main () {
  let mut file = fs::read_to_string("examples/fanclub.json").unwrap();
  let file: Vec<&str> = file.split("\n").collect();
  let schema_parser = SchemaParser::new();
  for json in file {
    schema_parser.write(&json)?;
  }
  let result = schema_parser.read();
  println!("{:?}", result);
}

Usage: in JavaScript

Make sure your environment is setup for Web Assembly usage.

import { SchemaParser } from "mongodb-schema-parser";

const schemaParser = new SchemaParser()

// get the json file
fetch('./fanclub.json')
  .then(response => response.text())
  .then(data => {
    var json = data.split("\n")
    for (var i = 0; i < json.length; i++) {
      if (json[i] !== '') {
        // feed the parser json line by line
        schemaParser.write(json[i])
      }
    }
    // get the result as a json string
    var result = schemaParser.toJson()
    console.log(result)
  })

Installation

$ cargo add mongodb-schema-parser 

License

Apache-2.0

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago