dragskills-model
v1.0.1
Published
This project uses **Mongoose** for MongoDB and includes several schemas to manage user data, skills, and user roles in a structured and modular way.
Readme
DragSkills Project
This project uses Mongoose for MongoDB and includes several schemas to manage user data, skills, and user roles in a structured and modular way.
Project Structure
This project includes the following main models:
- User Model (
userModel): Represents the users of the system. - Role Model (
roleModel): Defines the various roles of users. - Skill Model (
SkillModel): A catalog of skills. - User Skills Model (
usersSkillModel): Stores each user's skills and their respective experience.
Installation
To install the necessary packages, make sure you have Node.js and npm installed. Then, run the following command:
npm install dragskills-modelModel Setup
Models can be imported wherever needed. All models are exported from index.js:
const { userModel, roleModel, SkillModel, usersSkillModel } = require('dragskills-model');Example Usage
To create a new user skill entry:
const newUserSkill = new usersSkillModel({
user: userId, // Replace with the actual user ID
skill: skillId, // Replace with the actual skill ID
experience: 3 // Define the user’s experience level (in years)
});
newUserSkill.save()
.then((doc) => {
console.log("User skill saved:", doc);
})
.catch((error) => {
console.error("Error saving user skill:", error);
});