获取MongoDB shell脚本输出?
你可以使用printjson()或print()获取MongoDB shell脚本输出。 让我们创建一个对象数组。
以下是创建一个对象数组的查询。
> var studentDetails=[{"StudentName":"John","StudentAge":21}, {"StudentName":"Carol","StudentAge":24},{"StudentName":"David","StudentAge":25}];
以下是使用printjson()获取Mongo shell脚本输出的查询−
> printjson(studentDetails);
以下将产生如下输出−
[ { "StudentName" : "John", "StudentAge" : 21 }, { "StudentName" : "Carol", "StudentAge" : 24 }, { "StudentName" : "David", "StudentAge" : 25 } ] > var studentDetails=[{"StudentName":"John","StudentAge":21}, {"StudentName":"Carol","StudentAge":24},{"StudentName":"David","StudentAge":25}];
广告