Home > Back-end >  How like SQL dynamic execution of directing
How like SQL dynamic execution of directing

Time:10-01

Side need to manipulate mongo. Can perform operations, according to the different grammar dynamic link library is also a dynamic ~

Such as: db. The userInfo. Find ({" age ": 22});
The db. The users. The save ({name: "zhangsan", the age: 25, sex: true});

Dynamic can parse, etc., how to perform these?

Like a JDBC SQL can directly call SQL statement execution ~

CodePudding user response:

As the similar structure of SQL statements, variable string concatenation

CodePudding user response:

DBCollection collection=the getCollection (" yourCollection ");
BasicDBObject document=new BasicDBObject ();
Document. The put (" id ", 1001);
Document. The put (" MSG ", "hello world mongo in Java")

The background is the need to know what conditions, not general, like SQL script directly,

CodePudding user response:

Try:
https://blog.csdn.net/sl543001/article/details/102823055
Although the demo didn't write, but in fact support dynamic parameter
  • Related