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
result = user_repo.increment_age({'name':'Nikola'}) | |
print(result.acknowledged) |
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
result = user_repo.update({'name':'Rubik'}, {'$set': {'name': "Nikola"}}) | |
print(result.acknowledged) |
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
class UserRepository(object): | |
def __init__(self): | |
mongoclient = MongoClient('localhost', 27017) | |
#mongoclient = MongoClient('mongodb://localhost:27017') | |
database = mongoclient.local | |
self._users = database.user | |
# Create operations | |
def insert(self, 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
print("---Read All---") | |
all_users = user_repo.read_all() | |
for user in all_users: | |
print(user) | |
print("--------------\n") | |
print("---Read Many--") | |
rc_users = user_repo.read_many({'blog':'rubikscode.net'}) |
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
class UserRepository(object): | |
def __init__(self): | |
mongoclient = MongoClient('localhost', 27017) | |
#mongoclient = MongoClient('mongodb://localhost:27017') | |
database = mongoclient.local | |
self._users = database.user | |
# Create operations | |
def insert(self, 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
user_1 = { | |
'name':"Vanja", | |
'age':29, | |
'blog':"eventroom.org" | |
} | |
user_2 = { | |
'name':"Marko", | |
'age':36, | |
'blog':"rubikscode.net" |
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
user = { | |
'name':"Rubik", | |
'age':33, | |
'blog':"rubikscode.net" | |
} | |
result = user_repo.insert(user) | |
print(result.acknowledged) |
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
class UserRepository(object): | |
def __init__(self): | |
mongoclient = MongoClient('localhost', 27017) | |
#mongoclient = MongoClient('mongodb://localhost:27017') | |
database = mongoclient.local | |
self._users = database.user | |
# Create operations | |
def insert(self, 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
user_repo = UserRepository() |
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
class UserRepository(object): | |
def __init__(self): | |
mongoclient = MongoClient('localhost', 27017) | |
#mongoclient = MongoClient('mongodb://localhost:27017') | |
database = mongoclient.local | |
self._users = database.user |