示例#1
0
 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'
             }})
示例#2
0
 def insert(self):
     """Inserts object to the database."""
     if not Database.find_one("users", {"username": self.username}):
         Database.insert(collection='users',
                         data=self.json())
示例#3
0
 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())