Query Documents

FerretDB supports standard MongoDB query operators, translated to PostgreSQL SQL internally.

Syntax

ferretdb
collection.find(filter, options)
collection.findOne(filter)

Example

ferretdb
const admins = await col
  .find({ role: 'admin', active: true })
  .sort({ createdAt: -1 })
  .limit(10)
  .toArray();

const recent = await col.find({
  createdAt: { $gte: new Date('2025-01-01') },
}).toArray();