mongoose-easy-crud

1.0.6 • Public • Published

mongoose-easy-crud

Mongoose Easy CRUD is a utility library for simplifying CRUD (Create, Read, Update, Delete) operations with Mongoose in MongoDB.

npm version License

npm

Table of Contents

Installation

First install Node.js and MongoDB. Then:

npm install -g mongoose-easy-crud

Usage

Create a Mongoose model with the required structure. For example, let's create an "Auto" model:

// Auto.js

const mongoose = require("mongoose");
const { Schema, model } = mongoose;

const AutoSchema = Schema(
  {
    brand: {
      type: String,
      required: true,
    },
    model: {
      type: String,
      required: true,
    },
    year: {
      type: Number,
      required: true,
    },
  },
  {
    timestamps: true,
  }
);

AutoSchema.statics.getFieldsInfo = function () {
  return Object.keys(this.schema.paths).map((field) => ({
    name: field,
    properties: this.schema.paths[field],
  }));
};

const Auto = model("Autos", AutoSchema);

module.exports = Auto;

Now, you can use mongoose-easy-crud to simplify CRUD operations with your Mongoose models.

generate-crud auto

Configuration

To use mongoose-easy-crud, ensure your project has the following folder structure:

  • project-root/: Your project's root directory.
  • src/: The source folder that holds your application's code.
    • models/: A subfolder where you store your Mongoose model files.
      • YourModel.js: Example Mongoose model file.

Contributing

Thank you for considering contributing to Mongoose Easy CRUD! Contributions are highly appreciated.

How to Contribute

  1. Fork the repository.
  2. Clone your forked repository: git clone https://github.com/your-username/mongoose-easy-crud.git.
  3. Install dependencies: npm install.
  4. Create a new branch for your feature: git checkout -b feature/your-feature.
  5. Make your changes and test them thoroughly.
  6. Commit your changes: git commit -m 'Add your feature'.
  7. Push your branch to your forked repository: git push origin feature/your-feature.
  8. Submit a pull request.

Coding Guidelines

Please follow the coding guidelines outlined in the project. If in doubt, refer to the CONTRIBUTING.md file.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project, you agree to abide by its terms.

Thank you for contributing to Mongoose Easy CRUD!

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Package Sidebar

Install

npm i mongoose-easy-crud

Weekly Downloads

3

Version

1.0.6

License

ISC

Unpacked Size

17.2 kB

Total Files

8

Last publish

Collaborators

  • sangheliosblack