ta and indexes
db.foo.update(query, object[, upsert_bool, multi_bool])
db.foo.validate( ) - SLOW
db.foo.getShardVersion() - only for use with sharding
db.foo.getShardDistribution() - prints statistics about data distributio
n in the cluster
>
//想要了解一个函数,可以不写括号()运行,即可打印出该函数的源代码
> db.foo.update
function (query, obj, upsert, multi) {
assert(query, "need a query");
assert(obj, "need an object");
var firstKey = null;
for (var k in obj) {
firstKey = k;
break;
} www.2cto.com
if (firstKey != null && firstKey[0] == "$") {
this._validateObject(obj);
} else {
this._validateForStorage(obj);
}
this._mongo.update(this._fullName, query, obj, upsert true : false, multi
true : false);
}
//当集合(表)和db原有的属性相同时
//如db.version()为得到版本的函数
//当你创建集合(表)时,创建了同名的时
//那运行db.version得到的时version()函数源代码
//办法是运行db.getCollection('version')