def remove(self, id=None): try: self.collection.remove({"_id": ObjectId(id)}) # 插入缓存数据库 insert_cache(self.db_name, self.table_name, 'remove', [{"_id": ObjectId(id)}]) return id except: return None
def insert(self, data=None): try: data['_id'] = ObjectId().__str__() self.collection.insert(data) insert_cache(self.db_name, self.table_name, 'insert', [data]) return data['_id'] except: return None
def insert(self, name=None): self.dict['_id'] = ObjectId().__str__() self.dict['name'] = name self.dict['create_time'] = datetime.now() try: self.collection.insert(self.dict) # 插入缓存数据库 insert_cache(self.db_name, self.table_name, 'insert', [self.dict]) return self.dict['_id'] except: return None
def update(self, id=None, name=None): update_dict = dict() update_dict['name'] = name try: self.collection.update({"_id": id}, {"$set": update_dict}) # 插入缓存数据库 insert_cache(self.db_name, self.table_name, 'update', [{ "_id": id }, { "$set": update_dict }]) return id except: return None
def update(self, id=None, name=None, equipment_list=None): try: update_dict = dict() if name: update_dict['name'] = name if isinstance(equipment_list, list): update_dict['equipment_list'] = equipment_list self.collection.update({"_id": id}, {"$set": update_dict}) # 插入缓存数据库 insert_cache(self.db_name, self.table_name, 'update', [{ "_id": id }, { "$set": update_dict }]) return id except: return None
def update(self, id=None, name=None, factory_id=None, workshop_id=None): update_dict = dict() if name: update_dict['name'] = name if factory_id: update_dict['factory_id'] = factory_id if workshop_id: update_dict['workshop_id'] = workshop_id if update_dict: self.collection.update({"_id": id}, {"$set": update_dict}) # 插入缓存数据库 insert_cache(self.db_name, self.table_name, 'update', [{ "_id": id }, { "$set": update_dict }]) return id else: return None
def update(self, id=None, group_id=None, start_time=None, end_time=None, name=None): update_dict = {} if group_id: update_dict['group_id'] = group_id if start_time: update_dict['start_time'] = start_time if name: update_dict['name'] = name if end_time: update_dict['end_time'] = end_time if update_dict: try: self.collection.update({"_id": id}, {"$set": update_dict}) # 插入缓存数据库 insert_cache(self.db_name, self.table_name, 'update', [{"_id": id}, {"$set": update_dict}]) return id except: return None else: return None
def update(self, id=None, name=None, factory_id=None, workshop_id=None, line_id=None, factory_number=None, factory_time=None, product_number=None): update_dict = {} if name: update_dict['name'] = name if factory_id: update_dict['factory_id'] = factory_id if workshop_id: update_dict['workshop_id'] = workshop_id if line_id: update_dict['line_id'] = line_id if factory_number: update_dict['factory_number'] = factory_number if factory_time: update_dict['factory_time'] = factory_time if product_number: update_dict['product_number'] = product_number if update_dict: try: self.collection.update({"_id": id}, {"$set": update_dict}) # 插入缓存数据库 insert_cache(self.db_name, self.table_name, 'update', [{ "_id": id }, { "$set": update_dict }]) return id except: return None else: return None
def insert(self, name=None, workshop_id=None, line_id=None, factory_number=None, factory_time=None, product_number=None): self.dict['_id'] = ObjectId().__str__() self.dict['name'] = name self.dict['line_id'] = line_id self.dict['factory_id'] = self.factory_id self.dict['workshop_id'] = workshop_id self.dict['factory_time'] = factory_time self.dict['factory_number'] = factory_number self.dict['product_number'] = product_number self.dict['create_time'] = datetime.now() try: self.collection.insert(self.dict) # 插入缓存数据库 insert_cache(self.db_name, self.table_name, 'insert', [self.dict]) return self.dict['_id'] except: return None