Description:
Insert data to a MongoDB database.
Syntax:
mongo_insert(fd,collection,T)
mongo_insert(fd,collection,cs)
Note:
The function inserts data of a table sequence or a cursor to a MongoDB database.
Parameters:
fd |
A MongoDB database object to be connected |
collection |
A MongoDB collection |
T |
A table sequence |
cs |
A cursor |
Return value:
Boolean value
Example:
|
A |
|
1 |
=mongo_open("mongodb://127.0.0.1:27017/mydb") |
Connect to mydb database in Mongo server with IP: 127.0.0.1 and port 27017 and without a user name and a password |
2 |
=demo.cursor("select NAME,GENDER,BIRTHDAY,DEPT,SALARY from employee where DEPT = 'R&D' ") |
Query data in a table and return it as a cursor |
3 |
=mongo_open("mongodb://127.0.0.1:27017/user0") |
Query data in a table and return it as a table sequence |
4 |
=mongo_insert(A1,"emp",A2) |
Insert data in A2’s cursor to mongodb’s emp collection |
5 |
=mongo_insert(A1,"emp",A3) |
Insert data in A3’s table sequence to mongodb’s emp collection |
6 |
=mongo_shell(A1,"emp.find()").fetch() |
Get data from emp collection |
7 |
=mongo_close(A1) |
Close MongoDB connection |