def find_one(cls, username): """Returns one query result.""" query = {} if username: query['username'] = username user = Database.find_one(collection="users", query=query) return user
def find_one(cls, name): """Returns one query result.""" query = {} if name: query['name'] = name DFGs = Database.find_one(collection="DFGs", query=query) return DFGs
def insert(self): job = Database.find_one("jobs", {"name": self.name}) if not job: Database.insert(collection='jobs', data=self.json()) else: # Check if last build is in job builds. If not, add it. if not Database.DATABASE['jobs'].find_one( { "builds.number": self.last_build['number'], "name": self.name }): Database.DATABASE['jobs'].update( {"name": self.name}, {"$addToSet": { "builds": self.last_build }}) # Update job # Database.DATABASE['jobs'].find_one_and_update( # {"name": self.name}, # {"$set": self.properties}) Database.DATABASE['jobs'].find_one_and_update( {"name": self.name}, {"$set": { 'lol': 'lol2' }})
def insert(self): """Inserts object to the database.""" if not Database.find_one("users", {"username": self.username}): Database.insert(collection='users', data=self.json())
def insert(self): if not Database.find_one(self.COLLECTION, { "build_number": self.build_number, "job_name": self.job_name }): Database.insert(collection='builds', data=self.json())