Skip to content

Commit

Permalink
Corregido problemas con git
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisGalHur committed Jul 12, 2023
1 parent 1b4e7ae commit 65bab32
Show file tree
Hide file tree
Showing 5 changed files with 653 additions and 0 deletions.
25 changes: 25 additions & 0 deletions itachallenge-user/src/main/resources/mongodb-init/chech-filter.bat
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 itachallenge-user/src/main/resources/mongodb-init/load-data.bat
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 itachallenge-user/src/main/resources/mongodb-init/load-data.sh
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 itachallenge-user/src/main/resources/mongodb-init/mongo-init.js
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");
Loading

0 comments on commit 65bab32

Please sign in to comment.