Starts-With Query



StartsWith

products = list(
    session.query(object_type=Product)
    # Call 'where_starts_with' on the field
    # Pass the prefix to search by
    .where_starts_with("Name", "Ch")
)

# Results will contain only Product documents having a 'Name' field
# that starts with any case variation of 'ch'
from "Products"
where startsWith(Name, "Ch")

StartsWith (case-sensitive)

products = list(
    session.query(object_type=Product)
    # Pass 'exact=True' to search for an EXACT prefix match
    .where_starts_with("Name", "Ch", exact=True)
)

# Results will contain only Product documents having a 'Name' field
# that starts with 'Ch'
from "Products"
where exact(startsWith(Name, "Ch"))

Negate StartsWith

products = list(
    session.query(object_type=Product)
    # Negate next statement
    .not_()
    # Call 'where_starts_with' on the field
    # Pass the prefix to search by
    .where_starts_with("Name", "Ch")
)
# Results will contain only Product documents having a 'Name' field
# that does NOT start with 'ch' or any other case variations of it
from "Products"
where (true and not startsWith(Name, "Ch"))