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")
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")
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")