mongo-schema-genrator
Version:
An module to convert normal JS object to Mongo Schema
24 lines (19 loc) • 871 B
JavaScript
const { toMongo } = require("./utility/index.js");
let option = {
required: [""],
unique: [""],
}
/**
* This function will convert your normal JSON Object to Mongo Schema
* @param {Object} object The JSON object
* @param {String} writeAt Destination where you want to write the code
* @param {Boolean} _default If you want to add default property automatically
* @param {option} options the options for making the schema
* @exports String The Schema Code
*/
function SchemaGenrator(object, writeAt = undefined, _default = false, options = {}) {
if (typeof (object) !== "object") throw new Error("Please provide an JSON object");
if (typeof (writeAt) !== "string") throw new Error("The folder destination should be string ");
return toMongo(object, writeAt, _default, false,options)
}
module.exports = SchemaGenrator;