支持的功能:8.0

下表详细介绍了支持 MongoDB 兼容性的 Firestore 支持的 MongoDB 8.0 功能。如需了解行为差异,请参阅行为差异

查询和投影运算符

具有 MongoDB 兼容性的 Firestore 支持以下查询和投影运算符:

数组运算符

运算符 支持
$all
$elemMatch
$size

按位运算符

运算符 支持
$bitsAllClear
$bitsAllSet
$bitsAnyClear
$bitsAnySet

评论运算符

运算符 支持
$comment

比较运算符

运算符 支持
$eq
$gt
$gte
$in
$lt
$lte
$ne
$nin

元素运算符

运算符 支持
$exists
$type

评估查询运算符

运算符 支持
$expr
$jsonSchema
$mod
$regex
$text
$where

逻辑运算符

运算符 支持
$and
$nor
$not
$or

投影运算符

运算符 支持
$
$elemMatch
$meta
$slice

更新运算符

具有 MongoDB 兼容性的 Firestore 支持以下更新运算符。

数组运算符

运算符 支持
$
$[]
$[<identifier>]
$addToSet
$pop
$pull
$pullAll
$push

按位运算符

运算符 支持
$bit

字段运算符

运算符 支持
$currentDate
$inc
$max
$min
$mul
$rename
$set
$setOnInsert
$unset

更新修饰符

修饰符 支持
$each
$position
$slice
$sort

汇总流水线运算符

具有 MongoDB 兼容性的 Firestore 支持以下汇总流水线运算符。

累加器表达式

表达式 支持
$accumulator
$addToSet
$avg
$bottom
$bottomN
$count
$first
$firstN
$last
$lastN
$max
$min
$minN
$push
$stdDevPop
$stdDevSamp
$sum
$top
$topN

算术运算符

运算符 支持
$abs
$add
$ceil
$divide
$exp
$floor
$ln
$log
$log10
$mod
$multiply
$pow
$round
$sqrt
$subtract
$trunc

数组运算符

运算符 支持
$arrayElemAt
$arrayToObject
$concatArrays
$filter
$firstN
$in
$indexOfArray
$isArray
$lastN
$maxN
$minN
$objectToArray
$range
$reduce
$reverseArray
$size
$slice
$sortArray
$zip

布尔运算符

运算符 支持
$and
$not
$or

比较运算符

运算符 支持
$cmp
$eq
$gt
$gte
$lt
$lte
$ne

条件表达式运算符

运算符 支持
$cond
$ifNull
$switch

数据大小运算符

运算符 支持
$binarySize
$bsonSize

日期运算符

运算符 支持
$dateAdd
$dateDiff
$dateFromParts
$dateFromString
$dateSubtract
$dateToParts
$dateToString
$dateTrunc
$dayOfMonth
$dayOfWeek
$dayOfYear
$hour
$isoDayOfWeek
$isoWeek
$isoWeekYear
$millisecond
$minute
$month
$second
$tsIncrement
$tsSecond
$week
$year

其他运算符

运算符 支持
$getField
$literal
$mergeObjects
$natural
$rand
$sampleRate

集合运算符

运算符 支持
$allElementsTrue
$anyElementTrue
$setDifference
$setEquals
$setIntersection
$setIsSubset
$setUnion
$setWindowFields

阶段运算符

运算符 支持
$addFields
$bucket
$bucketAuto
$changeStreams
$collStats
$count
$currentOp
$documents
$facet
$geoNear
$graphLookup
$group
$indexStats
$limit
$listLocalSessions
$listSessions
$lookup
$match
$merge
$out
$planCacheStats
$project
$redact
$replaceRoot
$replaceWith
$sample
$set
$setWindowFields
$skip
$sort
$sortByCount
$unionWith
$unset
$unwind

字符串运算符

运算符 支持
$concat
$indexOfBytes
$indexOfCP
$ltrim
$regexFind
$regexFindAll
$regexMatch
$replaceAll
$replaceOne
$rtrim
$split
$strcasecmp
$strLenBytes
$strLenCP
$substr
$substrBytes
$substrCP
$toLower
$toUpper
$trim

系统变量

变量 支持
$$CLUSTERTIME No
$$CURRENT
$$DESCEND No
$$KEEP
$$NOW Yes
$$PRUNE
$$REMOVE Yes
$$ROOT

文本搜索运算符

运算符 支持
$meta
$search

三角函数运算符

运算符 支持
$acos
$acosh
$asin
$asinh
$atan
$atan2
$atanh
$cos
$cosh
$degreesToRadians
$radiansToDegrees
$sin
$sinh
$tan
$tanh

类型转换运算符

运算符 支持
$convert
$isNumber
$toBool
$toDate
$toDecimal
$toDouble
$toInt
$toLong
$toObjectId
$toString
$type

变量运算符

运算符 支持
$let
$map

地理空间

具有 MongoDB 兼容性的 Firestore 支持以下地理空间运算符。

几何形状说明符

说明符 支持
$box
$center
$centerSphere
$geometry
$maxDistance
$minDistance
$polygon
$uniqueDocs

查询选择器

选择器 支持
$geoIntersects
$geoWithin
$near
$nearSphere
$nearSphere
$uniqueDocs

索引和索引属性

具有 MongoDB 兼容性的 Firestore 支持以下索引和索引运算符。

索引

索引类型 支持
2 天
2dsphere
建筑
经过哈希处理
多键
单字段
文本

索引属性

属性 支持
背景
不区分大小写
隐藏
部分
非稀疏
稀疏
文本
TTL
唯一
通配符
向量

数据库命令

具有 MongoDB 兼容性的 Firestore 支持以下数据库命令。

聚合

命令 支持
aggregate
count
distinct
group

支持汇总中的 $group 阶段,但不支持“group”命令。

mapReduce

身份验证

命令 支持
authenticate
getnonce
logout

查询和写入操作

命令 支持
watch(变更流)
delete
eval
find
findAndModify
getLastError
getMore
getPrevError
GridFS
insert
parallelCollectionScan
replaceOne

replaceOne 驱动程序方法支持 update 命令。

resetError
update

会话命令

命令 支持
abortTransaction
commitTransaction
endSessions
killAllSessions
killAllSessionsByPattern
killSessions
refreshSessions
startSession

您可以使用 startSession 驱动程序方法启动会话。

管理命令

支持 MongoDB 的 Firestore 支持以下管理命令。

命令 支持
cloneCollectionAsCapped
collMod
collMod: expireAfterSeconds
convertToCapped
copydb
create
createIndexes

如需创建索引,请参阅管理索引

createView
currentOp
drop
dropDatabase

如需删除数据库,请参阅删除数据库

dropIndexes

如需删除索引,请参阅管理索引

filemd5
getAuditConfig
killCursors
killOp
listCollections
listDatabases
listIndexes
reIndex
renameCollection
setAuditConfig

诊断命令

命令 支持
buildInfo
collStats
connectionStatus
connPoolStats
dataSize
dbHash
dbStats
explain
explain: executionStats
features
hello
hostInfo
listCommands
profiler
serverStatus
top
whatsmyuri

角色管理命令

为了管理数据库访问权限,支持 MongoDB 的 Firestore 支持 Identity and Access Management 角色和权限

命令 支持
createRole
dropAllRolesFromDatabase
dropRole
grantRolesToRole
revokePrivilegesFromRole
revokeRolesFromRole
rolesInfo
updateRole

后续步骤