Python - collection.query.where()

Adds a new where clause to a query, which filters the data returned.

from nitric.resources import collection
profiles = collection('profiles').allow('reading')
query = collection("profiles").query().where("name", startsWith, 'T')

Parameters

  • Name
    field
    Required
    Required
    Type
    string
    Description

    The document field to query.

  • Name
    operation
    Required
    Required
    Type
    string
    Description

    The query operation to perform. Valid values are: startsWith, ==, !=, >=, <=, >, <.

  • Name
    value
    Required
    Required
    Type
    string or number
    Description

    The value to compare against.

Notes

Where clauses combined together are always considered AND

Examples

A simple query

from nitric.resources import collection
profiles = collection('profiles').allow('reading')
query = profiles.query().where("firstName", '==', 'Drake')

Combining where clauses

from nitric.resources import collection
profiles = collection('profiles').allow('reading')
query = profiles.query().where("firstName", '==', 'Drake').where('age', '>=', 21)

See also

Last updated on Dec 5, 2024