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

#lineWidth: 1.5 #font: Helvetica,sans-Serif #fontSize: 10 #leading: 1.6 #.this: fill=lightgray #.class: fill=white [<class>object|toString();toJSON()] [<this>MongoDB|operator[String]|getCollection();runCommand();oid();close()] [object] <:- [MongoDB] MongoDB operator[String] getCollection() runCommand() oid() close() object toString() toJSON()

Operator

operator[String]

Quickly get 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:


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