redis-om-python-flask-skeleton-app icon indicating copy to clipboard operation
redis-om-python-flask-skeleton-app copied to clipboard

Query len of list

Open dehuy69 opened this issue 3 years ago • 0 comments

Hello, how can i query condition which use len of list in redis_om?

class Person(JsonModel):
    first_name: str = Field(index=True)
    last_name: str = Field(index=True)
    age: PositiveInt = Field(index=True)
    address: Address
    skills: List[str] = Field(index=True)
    personal_statement: str = Field(index=True, full_text_search=True)

oneData = {
  "first_name": "A string, the person's first or given name",
  "last_name": "A string, the person's last or surname",
  "age": 36,
  "address": {
    "street_number": 56,
    "unit": "A string, optional unit number e.g. A or 1",
    "street_name": "A string, name of the street they live on",
    "city": "A string, name of the city they live in",
    "state": "A string, state, province or county that they live in",
    "postal_code": "A string, their zip or postal code",
    "country": "A string, country that they live in."
  },
  "personal_statement": "A string, free text personal statement",
  "skills": [
    "A string: a skill the person has",
    "A string: another still that the person has"
  ]
}

person = Person(**oneData)
person.save()

Migrator().run()
Person.find((Person.skills.__len__() > 1).all() 

I want query condition of length of skills list Can not find out anything in document and I tried many ways. Pls help!

dehuy69 avatar Jul 25 '22 10:07 dehuy69