Appwrite Databases have been enhanced with the introduction of two highly anticipated query methods: ‘or’ and ‘contains’. These additions, including array element matching, partial text searching, and the ability to perform logical OR queries, offer increased flexibility in data management.

The ‘contains’ feature now enables us to conduct more extensive searches by matching any portion of text within a substring. This proves incredibly beneficial for searching through large texts or when the exact location of keywords is uncertain.

db.listDocuments(
    '<DATABASE_ID>',
    '<COLLECTION_ID>', 
    [
        Query.contains('content', ['happy', 'love']),
    ]
   )

The logical OR operator introduces the capability to combine queries within an OR condition, enabling the grouping of multiple queries for a more versatile search experience. To apply the OR operator, simply use Query.or([…]) within the query array, ensuring that at least two queries are included in the nested array.

db.listDocuments(
    '<DATABASE_ID>',
    '<COLLECTION_ID>',
        [
        Query.or([
            Query.contains('name','ivy'),
            Query.greaterThan('age',30)
            ])
        ]
  )

The above query would return records where the name attribute contains the characters “ivy” or records where the age is greater than 30.

Get Started

Just like messaging, server-side rendering (SSR), and two-factor authentication (2FA), database functionalities are not yet available. Nonetheless, for those who are keen to get a head start, exploring Dennis Ivy’s product tour is recommended as a way to prepare for the upcoming release. It has been announced that version 1.5 is expected to launch in March, with availability on both cloud and self-hosted platforms.

Conclusion

The introduction of ‘contains’ and ‘or’ operations in the database will significantly simplify my work, allowing me to condense several processes into just one. I’m particularly excited about the ability to use the ‘contains’ method within an array, which is a game-changer for efficiency.

I’d love to hear what your favourite announcement has been so far. We’ve got one more day left of announcements. What do you think the next is? Let me know over on Twitter/X or in the comments below.

As always, stay tuned, as I will be releasing articles all week covering Appwrite’s announcements.

Further Reading