-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b4e7ae
commit 65bab32
Showing
5 changed files
with
653 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
itachallenge-user/src/main/resources/mongodb-init/chech-filter.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@echo off | ||
echo Beginning of insertion | ||
|
||
echo "Inserting first object..." | ||
mongosh user --eval "db.user_challenge.insertOne({'_id': '2a9bda26-10f2-11ee-be56-0242ac120002', user_id: '2dcacb291-b4aa-4029-8e9b-284c8ca80296', challenge_id: 'dcacb291-b4aa-4029-8e9b-284c8ca80296' })" | ||
|
||
|
||
IF NOT ERRORLEVEL 1 ( | ||
echo "First object inserted successfully." | ||
) ELSE ( | ||
echo "Error occurred while inserting the first object." | ||
) | ||
|
||
echo "Inserting duplicate object..." | ||
mongosh user --eval "db.user_challenge.insertOne({'_id': '3a9bda26-10f2-11ee-be56-0242ac120002', user_id: '2dcacb291-b4aa-4029-8e9b-284c8ca80296', challenge_id: 'dcacb291-b4aa-4029-8e9b-284c8ca80296' })" | ||
|
||
IF ERRORLEVEL 1 ( | ||
echo "Duplicate object not inserted. Unique index is working." | ||
) ELSE ( | ||
echo "Error occurred. Unique index might not be working." | ||
) | ||
|
||
echo Made it | ||
pause | ||
exit |
10 changes: 10 additions & 0 deletions
10
itachallenge-user/src/main/resources/mongodb-init/load-data.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@echo off | ||
echo Beginning of insertion | ||
|
||
mongoimport --db=user --collection=user_score --jsonArray --file=user_score.json | ||
|
||
echo "Creating unique index in user_score collection" | ||
mongosh --eval "db.getSiblingDB('user').user_score.createIndex({ user_id: 1, challenge_id: 1 }, { unique: true })" | ||
|
||
echo Made it | ||
exit |
11 changes: 11 additions & 0 deletions
11
itachallenge-user/src/main/resources/mongodb-init/load-data.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
echo "Beginning of insertion" | ||
|
||
mongoimport --db=user --collection=user_score --jsonArray --file=user_score.json | ||
|
||
echo "Creating unique index in user_score collection" | ||
mongosh --eval "db.getSiblingDB('user').user_score.createIndex({ user_id: 1, challenge_id: 1 }, { unique: true })" | ||
|
||
echo "Made it" | ||
exit |
11 changes: 11 additions & 0 deletions
11
itachallenge-user/src/main/resources/mongodb-init/mongo-init.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//create user logged as root User | ||
db.createUser({ | ||
user: "admin_user", | ||
pwd: "BYBcMJEEWw5egRUo", | ||
roles: [ | ||
{ role: "dbUsersOwner", db: "user" } | ||
] | ||
}); | ||
|
||
//create collections | ||
db.createCollection("users"); |
Oops, something went wrong.