Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add database seeding script to populate meds and users; Add route to #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vsrodriguez3
Copy link
Collaborator

@vsrodriguez3 vsrodriguez3 commented Nov 26, 2024

get all users

Description

  1. What does this PR do?

    • Adds a seeding script to populate the database with sample data for medications and users.
  2. List out what you did:

    • Created a new src/seeds/seedDatabase.js file for seeding the database.
    • Utilized the User and Medication models to ensure all data adheres to model-specific validation and logic.
    • Configured the script to:
      • Clear existing data from the users and medications collections.
      • Seed the database with sample users and medications.
      • Log success or failure messages in the terminal.
    • Updated the README to include detailed instructions on how to run the seeding script.

Related Issue

N/A

Type of Changes

  • feature addition and documentation update

Acceptance Criteria

  • populate the database with sample Inventory and sample users

Before

No sample data existed in the database.

After

Sample data has been seeded.
Example Output (for Users):

{
  "_id": "6489f111bde56c001e9e1aa1",
  "firstName": "Admin",
  "email": "[email protected]",
  "password": "$2b$10$eW5DjhOtaPwM/KxU0N2eZOU41jnpJqlI/lPpuFTB/X/Y1ZgxhsdpG",
  "role": "admin",
  "store": "Main Clinic",
  "createdAt": "2024-11-24T02:02:07.237Z",
  "updatedAt": "2024-11-24T02:02:07.237Z"
}

Testing Instructions

  1. Install Dependencies:
    Ensure all dependencies are installed:

    npm install
  2. Run the Seeder:
    Run the script using the npm run seed command:

    npm run seed
  3. Check the Output:

    • Confirm that the terminal logs show success messages like:
      • "MongoDB connected..."
      • "Existing data cleared!"
      • "Users seeded!"
      • "Medications seeded!"
    • Ensure no errors are logged.
  4. Verify Data:

    • Use the GET endpoints for medications and users to confirm seeded data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants