ProxyMongoInsert

 

Insert data to MongoDB.

To use MongoDB, you need to have ProxyMongoDB.exe program running. (  https://files.autobase.biz/FileDownLoad/FileDownLoad.aspx?Folder=Proxy )

 

int @ProxyMongoInsert(int connection_id, string collection_name, string text);

 

Parameters

int connection_id : Connection ID

sstring collection_name : Collection Name

string text : JSON Text to Insert data

 

Return Value

Returns 1 if it succeeds, and 0 if it fails.

 

Example

connection_id = @ProxyMongoOpen("mongodb://192.168.1.149", "test");
if(connection_id == 0)
{
   @Message("Error. connection_id == 0");
   return;
}

object t = @DateTimeNow();
int year = @DateTimeYear(t);
int month = @DateTimeMonth(t);
int day = @DateTimeDay(t);
int hour = @DateTimeHour(t);
int minute = @DateTimeMinute(t);
int second = @DateTimeSecond(t);
int millisecond = @DateTimeMillisecond(t);

string time_string;
@sprintf(time_string, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", year, month, day, hour, minute, second, millisecond);
string text;
int count = 50;
@sprintf(text, "{PersonDate:ISODate('%s'), PersonCount:%d, PersonText:'Text'}", time_string ,count);
int retn;

retn = @ProxyMongoInsert(connection_id, "things", text);
@ProxyMongoClose(connection_id);
if(retn == 0){
   @MessageBox(@GetLastError(), "MongoInsert Error", MB_OK);
   return;
}

 

Description : Example of opening and using the test database of the 192.168.1.149 IP

 

Version Information

Supported Version: 10.3.5 or higher

 

Related Helps

@ProxyMongoClose()

@ProxyMongoDeleteMany()

@ProxyMongoDeleteOne()

@ProxyMongoFill()

@ProxyMongoInsert()

@ProxyMongoOpen()

@ProxyMongoUpdateMany()

@ProxyMongoUpdateOne()