Object built-in object

Object MongoDB

mongodb database connection object

Use db.open or db.openMongoDB create, create method:

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

Inheritance

Subscript operation

Quickly obtain the specified collection access object

1
readonly MongoCollection MongoDB[String];

Used to quickly obtain 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, specify the name of the collection

Return result:


runCommand

Specify a MongoDB database command

1
Object 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 2
Object 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

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

Call parameters:

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

Return result:

  • MongoID , the new _objectid object

close

Close the current database connection

1
MongoDB.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

1
String 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

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

Call parameters:

  • key : String, unused

Return result:

  • Value , returns a value containing JSON serializable