Skip to content

MongoDB Manifest API

MongoDB 集合方法,用于插入、查询、更新和聚合文档。

1 class · 4 methods

Collection

4 methods

驱动和 mongo shell 暴露的集合级操作。

apiVersion: <group>/<version>

向集合中插入单个文档。

Parameters

NameTypeDescription
groupstringAPI group; core resources omit the group prefix.
versionstringStable version such as v1, beta1.

Returns

void

Example

kubernetes
apiVersion: apps/v1
kind: <Kind>

返回匹配查询的文档游标,可选投影字段。

Parameters

NameTypeDescription
KindstringPascalCase resource kind.

Returns

void

Example

kubernetes
kind: Deployment
metadata: name: <string> namespace: <string> labels: <map>

使用 $set 等更新操作符更新匹配 filter 的第一个文档。

Parameters

NameTypeDescription
namestringUnique name within the namespace.
namespacestringNamespace; defaults to 'default'.
labelsmap<string,string>Key/value pairs for selection and grouping.

Returns

void

Example

kubernetes
metadata:
  name: nginx
  namespace: web
  labels:
    app: nginx
spec: <resource-specific-schema>

删除匹配 filter 的第一个文档。

Parameters

NameTypeDescription
schemaobjectKind-specific spec, e.g. containers for a Pod.

Returns

void

Example

kubernetes
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    spec:
      containers:
        - name: nginx
          image: nginx:1.27