# mongoose-schema-clone

> Clone mongoose schema to new schema

Latest version **0.1.0** (published 2020-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongoose-schema-clone
pnpm add mongoose-schema-clone
yarn add mongoose-schema-clone
bun add mongoose-schema-clone
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-12-30 |
| First published | 2020-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 8.2.1 |
| Dependencies | 1 |
| Unpacked size | 11.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Vishal Turi |
| Maintainers | turivishal |
| Keywords | mongoose-schema-clone, schema-clone, mongoose-schema, schema |

## Links

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

## Dependencies (1)

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

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2020-12-30
- 0.0.10 — 2020-12-28
- 0.0.9 — 2020-12-28
- 0.0.1 — 2020-12-28

## README

# Mongoose Schema Clone

[![Version](https://img.shields.io/github/v/release/turivishal/mongoose-schema-clone)](https://github.com/turivishal/mongoose-schema-clone/tree/0.1.0)
[![Version](https://img.shields.io/github/v/release/turivishal/mongoose-schema-clone?color=red&label=npm)](https://www.npmjs.com/package/mongoose-schema-clone)

Deep clone and Returns a copy of the schema, Adds key path / schema type pairs to this schema and You can also add another schema and copy over all paths, virtuals, getters, setters, indexes, methods, and statics.

### FEATURES:
* Deep Clone Schema
* Copy paths, virtuals, getters, setters, indexes, methods, and statics

### INSTALLATION:
```
npm install --save mongoose-schema-clone
```

### USAGE:
```
const mongooseSchemaClone = require("mongoose-schema-clone");
```

### EXAMPLE:
```
const mongoose = require("mongoose");
const mongooseSchemaClone = require("mongoose-schema-clone");

const ParentSchema = new mongoose.Schema({
    name: { type: String },
    logo: { type: String }
});

const ChildSchema = mongooseSchemaClone(ParentSchema, {
    address: { 
        type: [{
            location: { type: String },
            city: { type: String },
            state: { type: String },
            country: { type: String },
            postalCode: { type: String }
        }] 
    }
});
```

### SOURCE:
The source is [mongoose-npm](https://www.npmjs.com/package/mongoose) method [add()](https://mongoosejs.com/docs/api/schema.html#schema_Schema-add).
```
const mongoose = require("mongoose");

module.exports = (Schema, Definition) => {
    return new mongoose.Schema(Definition).add(Schema);
}
```

### CONTACT US:
Email: turivishal@gmail.com

### LICENSE:
Mongoose Schema Clone is released under the [MIT License](http://www.opensource.org/licenses/MIT).

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