cursor.toArray()
項目一覧
cursor.toArray()
重要
mongosh メソッド
このページでは、
mongosh
メソッドについて記載しています。これは Node.js などの言語固有のドライバーのドキュメントではありません。MongoDB API ドライバーについては、各言語の MongoDB ドライバー ドキュメントを参照してください。
The
toArray()
method returns an array that contains all the documents from a cursor. The method iterates completely the cursor, loading all the documents into RAM and exhausting the cursor.次の値を返します。 An array of documents.
Consider the following example that applies toArray()
to the cursor returned from the find()
method:
var allProductsArray = db.products.find().toArray(); if (allProductsArray.length > 0) { printjson (allProductsArray[0]); }
The variable allProductsArray
holds the array of documents returned by
toArray()
.
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
注意
このコマンドは、すべての MongoDB Atlas クラスターでサポートされています。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン