Note: You are viewing documentation for version v0 of Node.js. View the latest version.
Node.js - collection.query.where()
Adds a new where clause to a query, which filters the data returned.
import { collection } from '@nitric/sdk'
const profiles = collection('profiles').for('reading')
const profileQuery = 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
import { collection } from '@nitric/sdk'
const profiles = collection('profiles').for('reading')
const profileQuery = profiles.query().where('firstName', '==', 'Drake')
Combining where clauses
import { collection } from '@nitric/sdk'
const profiles = collection('profiles').for('reading')
const profileQuery = profiles
.query()
.where('firstName', '==', 'Drake')
.where('age', '>=', 21)