Skip to content

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.

License

Notifications You must be signed in to change notification settings

turivishal/mongoose-schema-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mongoose Schema Clone

Version Version

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 method add().

const mongoose = require("mongoose");

module.exports = (Schema, Definition) => {
    return new mongoose.Schema(Definition).add(Schema);
}

CONTACT US:

Email: [email protected]

LICENSE:

Mongoose Schema Clone is released under the MIT License.

About

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.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published