2.0.9 • Published 9 months ago

@pecoding/mongoose-schema v2.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Mongoose Schema Central Repository

This project provides a centralized collection of Mongoose schemas used across various Node.js projects within XXX. It ensures consistency and reusability of schema definitions, minimizing duplication and simplifying maintenance across the company’s projects.

Purpose

In many Node.js projects within the company, the same data models are reused. To ensure consistency and maintainability, this package centralizes schema definitions, making it easier to update and manage models across all relevant projects.

Installation

Install the package via npm:

npm install @pecoding/mongoose-schema

Usage

This package exports multiple Mongoose models, schemas, and validation functions. Below is a summary of the available exports and their intended usage.

Exported Models and Schemas

Agents

  • agents: Mongoose model for the agents collection.
  • agent_schema: Schema definition for agents.
  • validationAgent: Function to validate agents data.
  • validateSearchAgent: Function to validate search parameters for agents.
  • validationUpAgent: Validation function for updating agents data.

Config Agents

  • config_agents: Mongoose model for the config_agents collection.
  • config_agents_schema: Schema definition for config_agents.

OAuth

  • oauths: Mongoose model for the oauths collection.
  • oauth_schema: Schema definition for oauths.

Games Lists

  • games_lists: Mongoose model for the game_lists collection.
  • game_custom_lists: Mongoose model for the game_custom_lists collection.
  • game_list_schema: Schema definition for game_lists.
  • game_custom_schema: Schema definition for game_custom_lists.

Lunchings

  • lunchings: Mongoose model for the lunchings collection.
  • lunching_schema: Schema definition for lunchings.

Announcements

  • announcements: Mongoose model for the announcements collection.
  • announcement_schema: Schema definition for announcements.

Maintenances

  • maintenances: Mongoose model for the maintenances collection.
  • maintenance_schema: Schema definition for maintenances.

Members

  • members: Mongoose model for the members collection.
  • member_schema: Schema definition for members.
  • validationMember: Function to validate member data.
  • validateSearchUser: Function to validate search parameters for members.
  • validationupMember: Validation function for updating member data.
  • validationpass: Validation function for member passwords.

Daily Reports

  • dailyReportSimples: Mongoose model for the dailyReportSimples collection.
  • dailyReportsProducts: Mongoose model for dailyReportSimples.
  • dailyReports: Mongoose Mongoose model for the dailyReports collection.
  • dailyReportSimples_schema: Schema definition for dailyReportSimples.
  • dailyReportsProducts_schema: Schema definition for dailyReportSimples.
  • dailyReports: Schema definition for dailyReports.

Reports

  • reports: Mongoose model for the reports collection.
  • report_schema: Schema definition for reports.

Importing the schema

const mongoose = require('mongoose');
const { members, validationMember, agents } = require('@pecoding/mongoose-schema');

// Connect to MongoDB
mongoose.connect('mongodb://localhost:27017/mydatabase', {
  useNewUrlParser: true,
  useUnifiedTopology: true
})
.then(() => console.log('MongoDB connected!'))
.catch((err) => console.error('Connection error:', err));

// Example usage of the members model
const newMember = new members({
  name: 'Jane Doe',
  email: 'jane.doe@example.com',
  age: 28
});

// Validate the member data before saving
if (validationMember(newMember)) {
  newMember.save()
    .then(member => console.log('Member saved:', member))
    .catch(err => console.error('Error saving member:', err));
} else {
  console.error('Member validation failed');
}
2.0.9

9 months ago

2.0.8

10 months ago

2.0.7

10 months ago

2.0.6

10 months ago

2.0.5

10 months ago

2.0.4

10 months ago

2.0.3

10 months ago

2.0.2

10 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.0.0

10 months ago