Last active
August 29, 2015 14:26
-
-
Save askucher/b33253496f3f40c0b3a5 to your computer and use it in GitHub Desktop.
Reset db but keep an user
This file contains hidden or 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
| #!/bin/bash | |
| #DROP DATABASE and RESTORE THE USER | |
| #run it remotely | |
| # curl -s "https://gist.githubusercontent.com/askucher/b33253496f3f40c0b3a5/raw/d23d23fba3d184fb46095f57f3bc3d8952b5d7fd/reset-db.sh" | bash | |
| evals () | |
| { | |
| echo $1 | |
| mongo 45.55.228.172/ABL_V2 --eval "$1" | |
| } | |
| createc () { | |
| evals "db.createCollection('$1')" | |
| } | |
| evals "db.dropDatabase()" | |
| createc "users" | |
| createc "apikeys" | |
| createc "aaps" | |
| createc "locations" | |
| #create user | |
| evals ' | |
| db.users.save({ | |
| "_id" : ObjectId("55a377c7beb479ae04eb2b79"), | |
| "apiKeys" : [ | |
| ObjectId("55a377c7beb479ae04eb2b78"), | |
| ObjectId("55b5fb091db36c6cc7a78963") | |
| ], | |
| "calendarId" : "n3j8amidpm1rl92c525u4shk0k@group.calendar.google.com", | |
| "companyName" : "Steghno", | |
| "created" : ISODate("2015-07-13T08:33:11.034Z"), | |
| "currency" : "USD", | |
| "domainName" : "book.com", | |
| "email" : "a.stegno@gmail.com", | |
| "fullName" : "Andrey", | |
| "isActive" : true, | |
| "isEmailVerified" : true, | |
| "location" : ObjectId("55a377c7beb479ae04eb2b77"), | |
| "password" : "$2a$05$mTnIiecg9WR.DfHLm3aNReyVdOCE80mAc93upDsj8ExWT16Oq.cDO", | |
| "phoneNumber" : "1234243242342", | |
| "role" : "operator" | |
| }) | |
| ' | |
| #create secret key | |
| evals ' | |
| db.apikeys.save({ | |
| "_id" : ObjectId("55a377c7beb479ae04eb2b78"), | |
| "created" : ISODate("2015-07-13T08:33:11.007Z"), | |
| "ipWhitelist" : [], | |
| "key" : "e4e9d47eec24b4de16d1a106e306c1ae9feb2ec44c51ca61e77c04986f29b2899790a08de33d6d077dc82e33e98712dd5c9c79efa13d30c814a6bb5e6cefb04a", | |
| "permissions" : [ | |
| "activity:create", | |
| "activity:update", | |
| "activity:delete", | |
| "activity:read", | |
| "booking:create", | |
| "booking:update", | |
| "booking:delete", | |
| "booking:read" | |
| ], | |
| "public" : false, | |
| "secret" : | |
| "e37dc098daf72b186e17887f1ddac0d5faa7960f1dac120a72831f6b636c24845b771e62b9684dc3011406d24b8a59bdd8045478690388209b8dd77a067b0e0f", | |
| "status" : "active", | |
| "type" : "dashboard", | |
| "user" : ObjectId("55a377c7beb479ae04eb2b79") | |
| }) | |
| ' | |
| #create public key for api | |
| evals ' | |
| db.apikeys.save( | |
| { | |
| "_id" : ObjectId("55b5fb091db36c6cc7a78963"), | |
| "created" : ISODate("2015-07-13T08:33:11.007Z"), | |
| "ipWhitelist" : [], | |
| "key" : "e4e9d47eec24b4de16d1a106e306c1ae9feb2ec44c51ca61e77c04986f29b2899790a08de33d6d077dc82e33e98712dd5c9c79efa13d30c814a6bb5e6cefb04a", | |
| "permissions" : [ | |
| "activity:create", | |
| "activity:update", | |
| "activity:delete", | |
| "activity:read", | |
| "booking:create", | |
| "booking:update", | |
| "booking:delete", | |
| "booking:read" | |
| ], | |
| "public" : true, | |
| "secret" : "e37dc098daf72b186e17887f1ddac0d5faa7960f1dac120a72831f6b636c24845b771e62b9684dc3011406d24b8a59bdd8045478690388209b8dd77a067b0e0f", | |
| "status" : "active", | |
| "type" : "widget", | |
| "user" : ObjectId("55a377c7beb479ae04eb2b79") | |
| }) | |
| ' | |
| #create required price | |
| evals 'db.aaps.save({"_id" : ObjectId("55a377c7beb479ae04eb2b79"), "user": ObjectId("55a377c7beb479ae04eb2b79"), "name": "Adult", "status":"active"})' | |
| evals ' | |
| db.locations.save( | |
| { | |
| "_id" : ObjectId("55a377c7beb479ae04eb2b77"), | |
| "city" : "NY", | |
| "country" : "US", | |
| "countryCode": "us", | |
| "state" : "New york", | |
| "streetAddress" : "42 Christopher St", | |
| "location" : { | |
| "coordinates" : [ | |
| 30.52197699999999, | |
| 50.451785 | |
| ], | |
| "type" : "Point" | |
| }, | |
| "type" : "activity", | |
| "tag" : "Main Location" | |
| }) | |
| ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment