View a markdown version of this page

$asinh - Amazon DocumentDB

$asinh

New from version 8.0.1.

The $asinh operator in Amazon DocumentDB returns the inverse hyperbolic sine of a value. Use it in the aggregation pipeline to perform hyperbolic trigonometric calculations on numeric fields.

Parameters

  • expression: An expression that resolves to a number.

The result is in radians. To obtain degrees, apply $radiansToDegrees to the output.

The return type is double by default. If the input is a 128-bit decimal, the output is also a 128-bit decimal.

Example (MongoDB Shell)

The following example shows how to use the $asinh operator to calculate the inverse hyperbolic sine of numeric values.

Create sample documents

db.values.insertMany([ { "_id": 1, "value": 0 }, { "_id": 2, "value": 1 }, { "_id": 3, "value": -1 } ]);

Query example

db.values.aggregate([ { $project: { "result": { $asinh: "$value" } }} ]);

Output

[ { "_id": 1, "result": 0 }, { "_id": 2, "result": 0.881373587019543 }, { "_id": 3, "result": -0.881373587019543 } ]

Code examples

To view a code example for using the $asinh 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('values'); const result = await collection.aggregate([ { $project: { "result": { $asinh: "$value" } }} ]).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['values'] result = list(collection.aggregate([ { '$project': { 'result': { '$asinh': '$value' } }} ])) print(result) client.close() if __name__ == "__main__": main()