資料の翻訳は、「NoSQL」コースの一部として作成されました。
また、MongoDB Map-ReduceFrameworkの 2日間の集中コースに参加することをお勧めします。
- 1日目のトピック:CRUD-操作;フィールドによるフィルタリング。sort
、skip
、limit
;サブドキュメントのリクエスト。
- 2日間のトピック:map-reduceの概念。コンセプトpipeline
;集約の構造と構文。ステージ$match
;ステージ$group
;ステージ$lookup
。

MongoDB . MongoDB . MongoDB Atlas, , .
Atlas . , , . — , API- Atlas MongoDB , MongoDB Atlas.
, , MongoDB. , , . , , . , Atlas, Atlas. .

API- Atlas , . :
;
API-, ;
API.
, , Twilio . .
, Realm.


API Atlas
API- Atlas Realm.

API Atlas ( getOneCluster
):
/*
* Gets information about the requested cluster. If clusterName is empty, all clusters will be fetched.
* See https://docs.atlas.mongodb.com/reference/api/clusters-get-one
*
*/
exports = async function(username, password, projectID, clusterName)
{
const arg = {
scheme: 'https',
host: 'cloud.mongodb.com',
path: 'api/atlas/v1.0/groups/' + projectID +'/clusters/' +
clusterName,
username: username,
password: password,
headers: {'Content-Type': ['application/json'],
'Accept-Encoding': ['bzip, deflate']},
digestAuth:true
};
// The response body is a BSON.Binary object. Parse it and return.
response = await context.http.get(arg);
return EJSON.parse(response.body.text());
};
GitHub.
API MiniAtlas
— , . Realm Web SDK, REST; -.
, 6 :
API |
|
|
|
GET |
/getClusters |
|
POST |
/getClusters |
|
GET |
/getClusterState?clusterName:cn |
|
PATCH |
/modifyCluster |
|
POST |
/pauseCluster |
|
DELETE |
/deleteCluster?clusterName:cn |

getClusters
(: Value Secret):
/*
* GET getClusters
*
* Query Parameters
*
* None
*
* Response - Currently all values documented at https://docs.atlas.mongodb.com/reference/api/clusters-get-all/
*
*/
exports = async function(payload, response) {
var results = [];
const username = context.values.get("username");
const password = context.values.get("apiKey");
projectID = context.values.get("projectID");
// Sending an empty clusterName will return all clusters.
var clusterName = '';
response = await context.functions.execute("getOneCluster", username, password,
projectID, clusterName);
results = response.results;
return results;
};
- GitHub.
- URL-, API:

API
, API. API . :
exports = function(payload) {
const headers = context.request.requestHeaders
const { Authorization } = headers
const user_id = Authorization.toString().replace(/^Bearer/, '')
return user_id
};
MongoDB Realm , , / , API, OAuth 2.0 Facebook, Google Apple ID.
Google OAuth — , , .

. , , , API.

JQuery Realm.
MongoDB Stitch Browser SDK Google ( ) Google StitchAppClient.
let credential = new stitch.GoogleRedirectCredential();
client.auth.loginWithRedirect(credential);
, API , StitchAppClient
:
let userId = client.auth.authInfo.userId;
API. API createCluster
:
export const createCluster = (uid, data) => {
let url = `${baseURL}/createCluster`
const params = {
method: "post",
headers: {
"Content-Type": "application/json;charset=utf-8",
...(uid && { Authorization: uid })
},
...(data && { body: JSON.stringify(data) })
}
return fetch(url, params)
.then(handleErrors)
.then(response => response.json())
.catch(error => console.log(error) );
};
API webhooks.js.
Postman. API .

, , , ! . , .
"NoSQL"
«MongoDB Map-Reduce Framework»