mongoose-easy-crud
v1.0.6
Published
Package to create easy CRUD with mongoose and Swagger
Downloads
2
Maintainers
Readme
mongoose-easy-crud
Mongoose Easy CRUD is a utility library for simplifying CRUD (Create, Read, Update, Delete) operations with Mongoose in MongoDB.
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
- Fork the repository.
- Clone your forked repository:
git clone https://github.com/your-username/mongoose-easy-crud.git
. - Install dependencies:
npm install
. - Create a new branch for your feature:
git checkout -b feature/your-feature
. - Make your changes and test them thoroughly.
- Commit your changes:
git commit -m 'Add your feature'
. - Push your branch to your forked repository:
git push origin feature/your-feature
. - 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.