Contenu connexe
Similaire à MapReduce, Indexes, and Other MongoDB Features
Similaire à MapReduce, Indexes, and Other MongoDB Features (20)
MapReduce, Indexes, and Other MongoDB Features
- 8. update insert query insert query mongod
- 11. insert
query mongod
driver
- 13. insert
getlasterror
mongod
driver
- 54. > db.help()
DB methods:
db.addUser()
db.auth()
db.cloneDatabase()
db.commandHelp()
db.copyDatabase()
db.createCollection()
db.currentOp()
...
- 56. > var cursor = db.foo.find()
> cursor.help()
DBQuery help
.sort()
.limit()
.skip()
.count()
.size()
...
- 63. > cursor.count
function(applySkipLimit) {
var cmd = {count : this._collection.getName()};;
if (this._query) {
if (this._special) {
cmd.query = this._query.query;;
}
else {
cmd.query = this._query;;
}
}
cmd.fields = this._fields || {};;
if (applySkipLimit) {
if (this._limit) {
cmd.limit = this._limit;;
...
- 64. function(x) {
// prep cmd
...
// run command
var res = this._db.runCommand(cmd);;
// return result
...
}
- 67. > db.runCommand({listCommands : 1})
{
"commands" : {
"$eval" : {...},
"assertinfo : {...},
"authenticate" : {...},
"buildinfo" : {...},
"clean" : {...},
"clone" : {...},
"cloneCollection" : {...},
"cloneCollectionAsCapped" : {...},
"closeAllDatabases" : {...},
...
- 71. > db.commandHelp("distinct")
help for: distinct: {
distinct : 'collection name',
key : 'a.b' }
> db.commandHelp
function(name) {
var c = {};;
c[name] = 1;;
c.help = true;;
return this.runCommand(c).help;;
}
>
- 88. {
_id : 123,
name : "Fred",
email : "fred@example.com"
}
{
_id : 456,
name : "Paul",
phone : "555-5555",
picture : BinData
}
{
_id : 789,
email : "alice@example.com",
}
- 89. _id 40
name 32
email 20
phone 2
picture 17
pet 3
friends 40
hobbies 6
favorites 12
notes 14
- 91. {
_id : 123,
name : "Fred",
email : "fred@example.com"
}
- 100. reduce = function(prev, current) {
var count = 0;;
for (var egg in current) {
count += current[egg];;
}
return count;;
}
- 105. A B C D E F
_id : A, value : _id : C, value : _id : E, value :
_id : B, value : _id : D, value : _id : F, value :
- 119. > db.map.insert({location : [-40, 78]})
> db.map.insert({location : {
... x : -40,
... y : 78}})
> db.map.insert({location : {
... longitude : -40,
... latitude : 78}})
>
- 126. 1 degree of longitude at the equator:
1 degree of longitude near the poles:
- 131. please help
document stuff!
http://cookbook.mongodb.org
- 133. thank you!
@kchodorow
http://www.snailinaturtleneck.com