def test_find_all(self): db = Mongodb('Northwind') pprint(db.find_all('customers'))
def test_find_by(self): db = Mongodb('Northwind') pprint(db.find_by('customers', {'City': 'Berlin'}))
from pprint import pprint import re from week5.mongodb import Mongodb db = Mongodb('Northwind') orders = db.find_by('orders', {'CustomerID': 'ALFKI'}) order_details = db.find_by( 'order-details', {'OrderID': { '$in': map(lambda x: x['OrderID'], orders) }}) products = db.find_by( 'products', {'ProductID': { '$in': map(lambda x: x['ProductID'], order_details) }}) # excercise 5.2 def excercise5_2(): for order in orders: print 'Order ID:' + str(order['OrderID']) pprint( map( lambda y: y['ProductName'], db.join_in( products, map(lambda x: x['ProductID'], db.join(order_details, order, 'OrderID', 'OrderID')),
from pprint import pprint import re from week5.mongodb import Mongodb db = Mongodb('Northwind') orders = db.find_by('orders', {'CustomerID': 'ALFKI'}) order_details = db.find_by( 'order-details', { 'OrderID': { '$in': map(lambda x: x['OrderID'], orders) } } ) products = db.find_by( 'products', { 'ProductID': { '$in': map(lambda x: x['ProductID'], order_details) } } ) # excercise 5.2 def excercise5_2(): for order in orders: print 'Order ID:' + str(order['OrderID']) pprint( map(