La traducción del material se preparó como parte del curso "NoSQL".
También invitamos a todos a unirse al curso intensivo de dos días de MongoDB Map-Reduce Framework.
- Temas del 1er día : operaciones CRUD; filtrado por campos;sort
,skip
,limit
; solicitudes de subdocumentos.
- Temas para 2 días : el concepto de map-reduce; conceptopipeline
; estructura y sintaxis de agregación; etapa$match
; etapa$group
; escenario$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());
};
API MiniAtlas
— , . Realm Web SDK, REST; -.
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
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.
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 .
, , , ! . , .
«MongoDB Map-Reduce Framework»