Invoke JS operation in batch processing MongoDB

Source: Internet
Author: User

In MongoDB, we can use the JS script to manipulate the data.

First, write the data Operation JS Script

New JS file writedata.js, write data operation content as follows:

var New Date ();d b.user.insert ({' name ': ' Zhang San ', ' Password ': ' 123456 ', ' UpdateTime ': Curtime});

Save the file, set the text encoding to "UTF-8", or it will appear garbled in Chinese.

Ii. Preparation of batch files

Create a new batch file Writedb.bat with the following contents:

@echo off D: CD D:\MongoDB\127.0.0.1:27017/normal--quiet E:\Test\writeData. JS Echo OK Pause

Where normal is the database name.

We can execute the batch file directly, or we can operate the database on a regular basis (such as cleaning up historical data) through the operating system's scheduled tasks.

Invoke JS operation in batch processing MongoDB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.