def find_files_by_query(cls, query): mongodbmanager.connect() files = File.objects(name__icontains = query) #do manual distinct returning_files = [] returning_files_hashes = [] for f in files: if f.hash not in returning_files_hashes: returning_files.append(f) returning_files_hashes.append(f.hash) return returning_files
def add(cls, id='', kootaj='', desc=''): if id != '': obj = Model.objects(Kootaj=id).first() else: obj = Model() if obj != None: obj.kootaj = kootaj obj.desc = desc obj.save()
def find(cls, _filter={}, page=-1, per_page=15, sort='personnel_id', order=1): try: obj = Model.objects(__raw__=_filter) result = [] for item in obj: result.append({ 'id': obj.id, 'kootaj': obj.kootaj, 'desc': obj.desc, }) return result except Exception, err: return err.message
def find_file(cls, name, hash, user): mongodbmanager.connect() return File.objects(name = name, hash = hash, session_id = user.session_id).first()
def find_files_for_user(cls, user): mongodbmanager.connect() return File.objects(session_id = user.session_id)
def count_files_by_hash(cls, hash): mongodbmanager.connect() return File.objects(hash = hash).count()
def find_files_by_hash(cls, hash): mongodbmanager.connect() return File.objects(hash = hash).all()
def find_file_by_hash_and_sessionid(cls, hash, session_id): mongodbmanager.connect() return File.objects(hash = hash, session_id = session_id).first()