Skip to content

Commit 6a56e2a

Browse files
Load Sample Data into MongoDB via a NPM Command (PalisadoesFoundation#1300)
* add db loader Signed-off-by: Ansh Goyal <[email protected]> * Update INSTALLATION.md * format:fix Signed-off-by: Ansh Goyal <[email protected]> * exclude script Signed-off-by: Ansh Goyal <[email protected]> * format:fix Signed-off-by: Ansh Goyal <[email protected]> * Update INSTALLATION.md * add more sample data Signed-off-by: Ansh Goyal <[email protected]> * Update INSTALLATION.md * fix ts issues Signed-off-by: Ansh Goyal <[email protected]> * format:fix Signed-off-by: Ansh Goyal <[email protected]> * refactor code Signed-off-by: Ansh Goyal <[email protected]> * modify sample data, update docm Signed-off-by: Ansh Goyal <[email protected]> --------- Signed-off-by: Ansh Goyal <[email protected]>
1 parent 47ba71d commit 6a56e2a

9 files changed

+530
-48
lines changed

INSTALLATION.md

+58-4
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,21 @@ This document provides instructions on how to set up and start a running instanc
2929
- [Setting up .env LAST\_RESORT\_SUPERADMIN\_EMAIL parameter](#setting-up-env-last_resort_superadmin_email-parameter)
3030
- [Configuring Google ReCAPTCHA](#configuring-google-recaptcha)
3131
- [Setting up RECAPTCHA\_SECRET\_KEY in .env file](#setting-up-recaptcha_secret_key-in-env-file)
32-
- [Setting up .env MAIL\_USERNAME and MAIL\_PASSWORD ReCAPTCHA Parameters](#setting-up-env-mail_username-and-mail_password-recaptcha-parameters)
32+
- [Setting up .env MAIL\_USERNAME and MAIL\_PASSWORD ReCAPTCHA Parameters](#setting-up-env-mail_username-and-mail_password-recaptcha-parameters)
3333
- [Setting up .env SMTP Variables](#setting-up-env-smtp-variables)
34-
- [Setting up Logger configurations (optional)](#setting-up-logger-configurations-optional)
35-
- [Setting up COLORIZE_LOGS in .env file](#setting-up-colorize_logs-in-env-file)
36-
- [Setting up LOG_LEVEL in .env file](#setting-up-log_level-in-env-file)
34+
- [Setting up Logger configurations *(optional)*](#setting-up-logger-configurations-optional)
35+
- [Setting up COLORIZE\_LOGS in .env file](#setting-up-colorize_logs-in-env-file)
36+
- [Setting up LOG\_LEVEL in .env file](#setting-up-log_level-in-env-file)
3737
- [Configuring Google Firebase](#configuring-google-firebase)
3838
- [Generate Firebase Keys for the Talawa Notification Service](#generate-firebase-keys-for-the-talawa-notification-service)
3939
- [(Mobile Developers Only) Applying the Firebase Keys to the Talawa Mobile App](#mobile-developers-only-applying-the-firebase-keys-to-the-talawa-mobile-app)
40+
- [Importing Sample Database](#importing-sample-database)
41+
- [Syntax:](#syntax)
42+
- [Examples:](#examples)
43+
- [Sample Data Overview:](#sample-data-overview)
44+
- [User Accounts and Organizations:](#user-accounts-and-organizations)
45+
- [Posts](#posts)
46+
- [Events](#events)
4047
- [Running Talawa-API](#running-talawa-api)
4148
- [How to Access the Talawa-API URL](#how-to-access-the-talawa-api-url)
4249
- [For Talawa-API Developers](#for-talawa-api-developers)
@@ -406,6 +413,53 @@ The key generated in the previous step is in a format suitable for use in a mobi
406413

407414
1. Undo the changes made to the `firebase_options.dart` file by overwriting it with the version you saved at the beginning of this section.
408415

416+
# Importing Sample Database
417+
418+
Talawa API contains a sample database importing function which can be used to import sample database.
419+
420+
## Syntax:
421+
422+
```npm run import:sample-data -- [args]```
423+
424+
You can pass the following arguments while running this script.
425+
426+
- ```--format```: Cleans the database before import. **Add this flag with caution. It will delete all of the existing data inside the talawa database.**
427+
- ```--items=```: Specify the items to add.
428+
- Following ```items``` can be specified, separated with a comma ```,```
429+
- ```users```: For users collection
430+
- ```organizations```: For organizations collection
431+
- ```events```: For events collection
432+
- ```posts```: For posts collection
433+
434+
## Examples:
435+
436+
- ```npm run import:sample-data```: This command will import the complete sample database without removing the existing data.
437+
- ```npm run import:sample-data -- --format```: This command will import the complete sample database after removing the existing data.
438+
- ```npm run import:sample-data -- --format --items=users,organizations```: This command will import the sample ```users``` and ```organizations``` collections after cleaning the existing data.
439+
- ```npm run import:sample-data -- --items=users,organizations```: This command will import the sample ```users``` and ```organizations``` collections without cleaning the existing data.
440+
441+
## Sample Data Overview:
442+
443+
The sample data contains organizations, users, events and posts. Here are the details for each of organizations and user account.
444+
445+
### User Accounts and Organizations:
446+
447+
| Email | Password | User Type | Joined Organization | Admin For |
448+
|-----------------------|----------|------------|---------------------|---------------------|
449+
| [email protected] | Pass@123 | USER | Angel Foundation | None |
450+
| [email protected] | Pass@123 | USER | Angel Foundation | None |
451+
| [email protected] | Pass@123 | USER | Angel Foundation | None |
452+
| [email protected] | Pass@123 | ADMIN | Angel Foundation | Angel Foundation |
453+
| [email protected] | Pass@123 | ADMIN | Hope Foundation | Hope Foundation |
454+
| [email protected] | Pass@123 | ADMIN | Dignity Foundation | Dignity Foundation |
455+
| [email protected] | Pass@123 | SUPERADMIN | The Unity Foundation | ALL |
456+
457+
### Posts
458+
There is one post inside the ```The Unity Foundation```
459+
460+
### Events
461+
There is one event inside the ```The Unity Foundation```
462+
409463
# Running Talawa-API
410464

411465
Talawa-api development server runs two processes simultaneously in the background. They are:

package-lock.json

+44-42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)