Object built-in object

objectMongoDB

mongodb database connection object

usedb.openordb.openMongoDBCreated, created by:

1
var mdb = db.openMongoDB("mongodb://host/db");

inheritance relationship

operator

operator[String]

Quickly get the specified collection access object

1
readonly MongoCollection MongoDB[String];

Used to quickly get collection objects using attributes, for example:

1
var test = mdb.test;

member function

getCollection

Get the specified collection access object

1
MongoCollection MongoDB.getCollection(String name);

Call parameters:

  • name: String, the name of the specified collection

return result:


runCommand

Specifies a MongoDB database command

1
Object MongoDB.runCommand(Object cmd);

Call parameters:

  • cmd: Object, a dictionary object specifying commands and parameters

return result:

  • Object, returns the command execution result

Specify a simple MongoDB database command

1 2
Object MongoDB.runCommand(String cmd, Value arg);

Call parameters:

  • cmd: String, specifies the command name
  • arg: Value, specifies the command parameter

return result:

  • Object, returns the command execution result

oid

Generate a mongodb _objectid object

1
MongoID MongoDB.oid(String hexStr = "");

Call parameters:

  • hexStr: String, initialize a hexadecimal string, generate a new id by default

return result:

  • MongoID, the new _objectid object

close

close the current database connection

1
MongoDB.close() async;

toString

Return the string representation of the object, generally return "[Native Object]", the object can be reimplemented according to its own characteristics

1
String MongoDB.toString();

return result:

  • String, returns a string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable properties defined by the object

1
Value MongoDB.toJSON(String key = "");

Call parameters:

  • key: String, not used

return result:

  • Value, which returns a JSON-serializable value