def query(self, *largs, **kargs): db = lookup(kargs, "db", default = None, destroy = True) join = lookup(kargs, "join", default = None, destroy = True) by = lookup(kargs, "by", default = None, destroy = True) if db is None: db = self.getdb() t = Table(self.cl._spec["name"]) if join is not None: t = t.join(join, by = by) if self.cl._parent is None: cur = lookup(kargs, "cur", default = None, destroy = True) orderby = lookup(kargs, "orderby", default = [], destroy = True) limit = lookup(kargs, "limit", default = None, destroy = True) offset = lookup(kargs, "offset", default = None, destroy = True) return db.query(columns = [All()], table = t, cond = And(*largs, **kargs), orderby = orderby, limit = limit, offset = offset, cur = cur) else: return ZooInfo(self.cl._parent).query(db = db, join = t, by = {self.cl._spec["primary_key"]}, *largs, **kargs)
def count(self, *largs, **kargs): db = lookup(kargs, "db", default = None, destroy = True) join = lookup(kargs, "join", default = None, destroy = True) by = lookup(kargs, "by", default = None, destroy = True) if db is None: db = self.getdb() t = Table(self.cl._spec["name"]) if join is not None: t = t.join(join, by = by) if self.cl._parent is None: groupby = lookup(kargs, "groupby", default = [], destroy = True) if type(groupby) == set: groupby = list(groupby) elif type(groupby) != list: groupby = [groupby] cur = db.query(columns = [Count(All())] + groupby, table = t, cond = And(*largs, **kargs), groupby = groupby) n = cur.fetchall() cur.close() return tomultidict(n, groupby) else: return ZooInfo(self.cl._parent).count(db = db, join = t, by = {self.cl._spec["primary_key"]}, *largs, **kargs)
def crosswalk(self): return Table(self.api, 't/crosswalk')
def monetize(self): return Table(self.api, 'places/monetize')
def table(self, table): return Table(self.api, 't/' + table)