Object MongoDB
mongodb database connection object
use db.open or db.openMongoDB Create, create method:
1var mdb = db.openMongoDB("mongodb://host/db");
Inheritance
Operator
operator[String]
Quickly get the specified collection access object
1readonly MongoCollection MongoDB[String];
Used to quickly obtain collection objects using attributes, for example:
1var test = mdb.test;
Member function
getCollection
Get the specified collection access object
1MongoCollection MongoDB.getCollection(String name);
Call parameters:
- name: String, specify the name of the collection
Return result:
- MongoCollection, Return the specified collection object
runCommand
Specify a MongoDB database command
1Object MongoDB.runCommand(Object cmd);
Call parameters:
- cmd: Object, a dictionary object specifying commands and parameters
Return result:
- Object, Return command execution result
Specify a simple MongoDB database command
1
2Object MongoDB.runCommand(String cmd,
Value arg);
Call parameters:
- cmd: String, specify the command name
- arg: Value, specify command parameters
Return result:
- Object, Return command execution result
oid
Generate a mongodb _objectid object
1MongoID MongoDB.oid(String hexStr = "");
Call parameters:
- hexStr: String, initialize a hexadecimal string, and generate a new id by default
Return result:
- MongoID, New _objectid object
close
Close the current database connection
1MongoDB.close() async;
toString
Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics
1String MongoDB.toString();
Return result:
- String, Returns the string representation of the object
toJSON
Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object
1Value MongoDB.toJSON(String key = "");
Call parameters:
- key: String, unused
Return result:
- Value, Returns a value containing JSON serializable