print("WelcometoMongoDBConsole"); Following is the output on the console - WelcometoMongoDBConsole Let us create an object. The query is as follows-&g"/> print("WelcometoMongoDBConsole"); Following is the output on the console - WelcometoMongoDBConsole Let us create an object. The query is as follows-&g">

Home  >  Article  >  Database  >  Is it possible to write to the MongoDB console within a JavaScript execution?

Is it possible to write to the MongoDB console within a JavaScript execution?

WBOY
WBOYforward
2023-09-24 15:57:06750browse

是否可以在 JavaScript 执行中写入 MongoDB 控制台?

To write on the console you need to use the print() method. The syntax is as follows -

print(“yourString”);

To display the object, you can use printjson(). The syntax is as follows -

printjson(yourObjectName);

Let us implement these two functions. The first query is shown below to display something -

> print("Welcome to MongoDB Console");

The following is the output on the console -

Welcome to MongoDB Console

Let us create an object. The query is as follows -

>studentInformation={"StudentName":"John","StudentAge":24,"StudentTechnicalSkills":["C","C++","Java","MongoDB","MySQL"]};
{
   "StudentName" : "John",
   "StudentAge" : 24,
   "StudentTechnicalSkills" : [
      "C",
      "C++",
      "Java",
      "MongoDB",
      "MySQL"
   ]
}

This is the query to display the above object "studentInformation" -

> printjson(studentInformation);

The following is the output -

{
   "StudentName" : "John",
   "StudentAge" : 24,
   "StudentTechnicalSkills" : [
      "C",
      "C++",
      "Java",
      "MongoDB",
      "MySQL"
   ]
}

The above is the detailed content of Is it possible to write to the MongoDB console within a JavaScript execution?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete