OPTIONS

Driver Syntax TableΒΆ

The documentation generally gives examples in JavaScript, use this chart to convert those examples to any language.

JavaScript Python PHP Ruby Java C++ C# Perl
[ ]
[]
array()
[]
BasicDBList
BSONObj

or

bson::bo
BsonArray
[ ]
{}
{}
new stdClass
{}
BasicDBObject
BSONObj
BsonDocument
{}
{ x : 1 }
{"x": 1}
array('x' => 1)
{'x' => 1}
BasicDBObjectBuilder.start().add("x", 1).get()
BSONObjBuilder().append("x", 1).obj();
BSON( "x" << 1 )
new BsonDocument("x", 1)
{ x : 1 }
connect("www.example.net")
Connection("www.example.net")
new Mongo("www.example.net")
MongoClient.new("www.example.net")
new Mongo("www.example.net", "dbname")
mongo::DBClientConnection conn;
conn.connect("www.example.net");
var server = MongoServer.Create("mongodb://www.example.net");
MongoDB::Connection->new(host => 'www.example.net')
cursor.next()
cursor.next()
$cursor->getNext()
cursor.next
cursor.next()
cursor.next()
foreach (var document in cursor)
$cursor->next()
cursor.hasNext()
Does not exist
$cursor->hasNext()
cursor.has_next?
cursor.hasNext()
cursor.more()
 
$cursor->has_next()
collection.findOne()
collection.find_one()
$collection->findOne()
collection.find_one
collection.findOne()
connection.findOne(namespace, query)
collection.FindOne()
$collection->find_one()
db.eval()
db.eval()
$db->execute()
db.eval("return sum(2,3);")
db.doEval()
connection.eval()
db.Eval(js)
$db->eval()