application/json
body
-
链接的 MongoDB Atlas 数据源的名称。它通常为
"mongodb-atlas"
,但如果您在创建数据源时选择了不同的名称,则在应用程序中可能具有不同的名称。 -
指定的数据源中的数据库名称。
-
指定的数据库中的集合名称。
-
匹配文档的 MongoDB 查询筛选条件。有关 Data API 支持的所有查询运算符的列表,请参阅查询运算符。
-
操作返回的匹配文档的 MongoDB 投影。
-
指示排序的字段名称和方向的 MongoDB 排序表达式。
-
响应中包含的匹配文档的最大数量。
-
要从响应中忽略的匹配文档的数量。
body
-
链接的 MongoDB Atlas 数据源的名称。它通常为
"mongodb-atlas"
,但如果您在创建数据源时选择了不同的名称,则在应用程序中可能具有不同的名称。 -
指定的数据源中的数据库名称。
-
指定的数据库中的集合名称。
-
匹配文档的 MongoDB 查询筛选条件。有关 Data API 支持的所有查询运算符的列表,请参阅查询运算符。
-
操作返回的匹配文档的 MongoDB 投影。
-
指示排序的字段名称和方向的 MongoDB 排序表达式。
-
响应中包含的匹配文档的最大数量。
-
要从响应中忽略的匹配文档的数量。
POST /动作/find
curl -s "https://data.mongodb-api.com/app/$CLIENT_APP_ID/endpoint/data/v1/action/find" \
-X POST \
-H "apiKey: $API_KEY" \
-H 'Content-Type: application/ejson' \
-H "Accept: application/json" \
-d '{
"dataSource": "mongodb-atlas",
"database": "learn-data-api",
"collection": "tasks",
"filter": {
"status": "complete"
},
"sort": { "completedAt": 1 },
"limit": 10
}'
请求示例
{
"sort": {
"completedAt": 1
},
"limit": 10,
"filter": {
"status": "complete"
},
"database": "todo",
"collection": "tasks",
"dataSource": "mongodb-atlas",
"projection": {
"text": 1,
"completedAt": 1
}
}
请求示例
{
"sort": {
"completedAt": 1
},
"limit": 10,
"filter": {
"status": "complete"
},
"database": "todo",
"collection": "tasks",
"dataSource": "mongodb-atlas",
"projection": {
"text": 1,
"completedAt": 1
}
}
响应示例 (200)
{
"documents": [
{
"_id": "6193504e1be4ab27791c8133",
"text": "Do the dishes",
"completedAt": "2022-05-16T20:22:01.104Z"
},
{
"_id": "6194604e1d38dc33792d8257",
"text": "Feed the dog",
"completedAt": "2022-05-17T05:12:42.828Z"
}
]
}
响应示例 (200)
{
"documents": [
{
"_id": {
"$oid": "6193504e1be4ab27791c8133"
},
"text": "Do the dishes",
"completedAt": {
"$date": {
"$numberLong": "1652732521104"
}
}
},
{
"_id": {
"$oid": "6194604e1d38dc33792d8257"
},
"text": "Feed the dog",
"completedAt": {
"$date": {
"$numberLong": "1652764362828"
}
}
}
]
}
响应示例 (400)
Errornoauthenticationspecified
{
"error": "no authentication methods were specified",
"error_code": "InvalidParameter",
"link": "string"
}
{
"error": "must specify some form of authentication (either email+password, api-key, or jwt) in the request header or body",
"error_code": "MissingParameter",
"link": "string"
}
响应示例 (401)
{
"error": "invalid session: error finding user for endpoint",
"error_code": "InvalidSession",
"link": "string"
}