首页 > 代码库 > Mongodb 执行eval命令

Mongodb 执行eval命令

procedure TForm1.BitBtn7Click(Sender: TObject);

var

   query,b1,b2:tbson;

   buf:tbsonbuffer;  

   code:tbsoncodewscope;

begin

  if dbman=nil then dbman:=tdbmanage.create;  

   code:=tbsoncodewscope.Create(‘function(){var a=db.testc.find();return a[0].name;}‘,bson([]));

   buf:=tbsonbuffer.Create;  buf.append(‘eval‘,code);

 

 query:=buf.finish;

  showmessage(query.Displaystr.ToString);

 b2:=dbman.mongodbs.mongo.command(‘prjdbs‘,query);  

 b1:=dbman.mongodbs.mongo.getLastErr(‘prjdbs‘);

 if b1<>nil then showmessage(b1.Displaystr.ToString);  

showmessage(b2.Displaystr.ToString);

end;

Mongodb 执行eval命令