def list_member(): return conn.find("member", {})
def list_stock(): return conn.find("stock", {})
def search_member_by_SID(sid): return conn.find("member", {"sid": sid}).next()
def search_member_by_name(name): return conn.find("member", {"name": name})
def search_member_by_ID(_id): return conn.find("member", {"_id": ObjectId(_id)}).next()
def list_tag(): return conn.find("tag", {})
def search_tag_by_id(id): _id = bson.ObjectId(id) return conn.find("tag", {"_id": _id}).next()
def search_tag_by_property(category, **props): cc_props = {} for key in props: cc_props["property." + key] = props[key] cc_props["category"] = category return conn.find("tag", cc_props)
def search_tag_by_name(name): return conn.find("tag", {"name": name})