Socket
Book a DemoInstallSign in
Socket

mongoose-docs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-docs

Automatically create documentation for Mongoose schemas.

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
15
150%
Maintainers
1
Weekly downloads
 
Created
Source

Mongoose Docs

Documentation for your project is very important but also very time-consuming. Programmers often need to leave documentation in the actual code for other developers and then write it again on the frontend for users who don't work with the code.

Mongoose-docs allows you to comment your Mongoose schemas in the codebase and output it in a JSON format that can be rendered on the frontend, so you won't need to copy-paste-copy-paste from your code to a Google Doc.

Generated Documentation

Mongoose Compatability

Mongoose Docs works with Mongoose 5.x and 6.x. However, you need to ensure you are using the correct combination of versions.

Mongoose VersionMongoose-Docs Version
v5.xv1.x
v6.xv2.x

Installation

npm install mongoose-docs --save

Usage

  • Create your schemas and models. Fields can have a new comment property in the schema type which will be outputted in the JSON.
  • Execute the mongooseDocsJSON function and pass in mongoose. It will return the analyzed structure in a readable JSON format.
  • Optional: execute the mongooseDocsOutputHTML function and pass in the result from mongooseDocsJSON and the system directory for the documentation HTML files.

Example

import {mongooseDocsJSON, mongooseDocsOutputHTML} from "mongoose-docs";
import mongoose, {Schema} from "mongoose";

// Your schemas and models
const schemaOptions = {
    timestamps: true,
    comment: "This collection contains all the users.",
};
const userSchema = new Schema({
    email: {
        type: String,
        comment: "This is the user email", // New comment property on schema type
        required: true,
    },
    password: {
        type: String,
        comment: "This is the hashed password", // New comment property on schema type
        required: true,
    },
}, schemaOptions);
mongoose.model('User', userSchema);

// Pass in the Mongoose instance with the models implemented.
const schemaJSON = mongooseDocsJSON(mongoose);

// Optional: Output documentation into HTML files
mongooseDocsOutputHTML(schemaJSON, __dirname + "/docs");

Keywords

developer-tools

FAQs

Package last updated on 24 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.