# mongoose-to-spark-schema

> Generate Spark StructType schema JSON from Mongoose model

Latest version **1.0.4** (published 2021-09-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongoose-to-spark-schema
pnpm add mongoose-to-spark-schema
yarn add mongoose-to-spark-schema
bun add mongoose-to-spark-schema
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-09-08 |
| First published | 2021-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Vishal Gauba |
| Maintainers | flamefractal |
| Keywords | spark, mongooose, structtype |

## Links

- npm: https://www.npmjs.com/package/mongoose-to-spark-schema
- Repository: https://github.com/FlameFractal/mongoose-to-spark-schema
- Homepage: https://github.com/FlameFractal/mongoose-to-spark-schema#readme
- Issues: https://github.com/FlameFractal/mongoose-to-spark-schema/issues
- npm.io page: https://npm.io/package/mongoose-to-spark-schema

## Dependencies (1)

- [mongoose](https://npm.io/package/mongoose.md) ^6.0.3

## Recent versions

- 1.0.4 (latest) — 2021-09-08
- 1.0.3 — 2021-09-06

## README

# mongoose-to-spark-schema

> Generate Spark StructType schema JSON from a Mongoose model

[![NPM version](https://badge.fury.io/js/mongoose-to-spark-schema.svg)](http://badge.fury.io/js/mongoose-to-spark-schema)

[![npm](https://nodei.co/npm/mongoose-to-spark-schema.png)](https://www.npmjs.com/package/mongoose-to-spark-schema)

## Install

```
$ git clone
$ cd mongoose-to-spark-schema
$ npm install
```

## Usage

```bash
// output to stdout
node index.js --model=./path-to-mongoose-model.js

// output to file
node index.js --model=./path-to-mongoose-model.js --output=./path-to-output-schema.json
```

### Caveats:
- Remove all dependencies from mongoose model file (plugins, hooks etc.) except `mongoose` before running.
- Fields with type `Mixed`/`Object` cannot be handled in Spark StructType. Either remove or replace with the exact structure of the object in the model file. 

## Todo

- [ ] export a `generateSchema()` function that can be imported within a NodeJS app.
    - parameter could be file path or mongoose model object

## Dependencies

- [mongoose](https://www.npmjs.com/package/mongoose)

---
_Source: https://npm.io/package/mongoose-to-spark-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
