MongoDB 常用命令

需求SQL 语句MongoDB 查询
等于WHERE age = 30{ age: 30 }
大于WHERE age > 30{ age: { $gt: 30 } }
范围WHERE age > 25 AND age <= 35{ age: { $gt: 25, $lte: 35 } }
逻辑与WHERE age = 30 AND status = 'active'{ age: 30, status: 'active' }
逻辑或WHERE status = 'inactive' OR age < 25{ $or: [ { status: 'inactive' }, { age: { $lt: 25 } } ] }
INWHERE tags IN ('tech', 'music'){ tags: { $in: ['tech', 'music'] } }
LIKEWHERE email LIKE '%example%'{ email: /example/ }
NOT NULLWHERE email IS NOT NULL{ email: { $exists: true } }
Last Updated:
Contributors: gclhaha