$radiansToDegrees - Amazon DocumentDB
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

$radiansToDegrees

New from version 8.0.1.

The $radiansToDegrees operator in Amazon DocumentDB converts a value from radians to degrees.

Parameters

  • expression: An expression that resolves to a numeric value in radians.

Example (MongoDB Shell)

The following example shows how to use the $radiansToDegrees operator to convert radian values to degrees.

Create sample documents

db.angles.insertMany([ { "_id": 1, "radians": 0 }, { "_id": 2, "radians": 1.5707963267948966 }, { "_id": 3, "radians": 3.141592653589793 }, { "_id": 4, "radians": 6.283185307179586 } ]);

Query example

db.angles.aggregate([ { $project: { "degrees": { $radiansToDegrees: "$radians" } }} ]);

Output

[ { "_id": 1, "degrees": 0 }, { "_id": 2, "degrees": 90 }, { "_id": 3, "degrees": 180 }, { "_id": 4, "degrees": 360 } ]

Code examples

To view a code example for using the $radiansToDegrees operator, choose the tab for the language that you want to use:

Node.js
const { MongoClient } = require('mongodb'); async function main() { const client = await MongoClient.connect('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'); const db = client.db('test'); const collection = db.collection('angles'); const result = await collection.aggregate([ { $project: { "degrees": { $radiansToDegrees: "$radians" } }} ]).toArray(); console.log(result); await client.close(); } main();
Python
from pymongo import MongoClient def main(): client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') db = client['test'] collection = db['angles'] result = list(collection.aggregate([ { '$project': { 'degrees': { '$radiansToDegrees': '$radians' } }} ])) print(result) client.close() if __name__ == "__main__": main()