To deliver data from MongoDB, we modify the sweetscomplete.domain.product.ProductService domain service class. As per the action-domain-responder pattern, the domain service has no knowledge of what format the output takes. The only concern of the new method is to make sure it delivers a list of sweetscomplete.entity.product.Product entities that contain the information needed. Formatting is handled by the responder class.
The new method, fetchAllKeysTitlesPricesForAjax(), returns a list of products that includes productKey, title, and price:
# sweetscomplete.domain.product.ProductService
def fetchAllKeysTitlesPricesForAjax(self, skip = 0, limit = 0) :
projection = dict({"productKey":1,"title":1,"price":1,"_id":0})
result = []
for doc in self.db.products.find(None, projection, skip, limit) :
result.append(doc)
return result
In addition, we need a very simple...