예제 #1
0
 def insert(self, *currency: Currency):
     if currency.__len__() == 1:
         self._db_connection.insert(self.collection(), currency[0].to_dict())
     elif currency.__len__() > 1:
         self._db_connection.insert_many(self.collection(),
                                         list(map(lambda this_currency: this_currency.to_dict(), currency)))
     else:
         print("CurrencyDao#insert: Nothing to insert")
예제 #2
0
 def update(self, *currency: Currency):
     if currency.__len__() == 1:
         self._db_connection.update_one(self.collection(), {'currency_code': currency[0].currency_code},
                                        currency[0].to_dict())
     elif currency.__len__() > 1:
         for l_currency in currency:
             self.update(l_currency)
     else:
         print("CurrencyDao#update: Nothing to update")
예제 #3
0
 def delete(self, *currency: Currency):
     if currency.__len__() == 1:
         self._db_connection.delete_one(self.collection(), {'currency_code': currency[0].currency_code})
     elif currency.__len__() > 1:
         self._db_connection.delete_many(self.collection(),
                                         {'currency_code': {
                                             "$set": list(map(lambda this_currency: this_currency.currency_code,
                                                              currency))}})
     else:
         print("CurrencyDao#delete: Nothing to delete")