mongo.find(rmongodb)
mongo.find()所属R语言包:rmongodb
Find records in a collection
集合中的查找记录
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Find records in a collection that match a given query.
一个集合,匹配给定查询的记录。
See http://www.mongodb.org/display/DOCS/Querying.
请参阅http://www.mongodb.org/display/DOCS/Querying。
用法----------Usage----------
mongo.find(mongo, ns, query=mongo.bson.empty(),
sort=mongo.bson.empty(), fields=mongo.bson.empty(),
limit=0L, skip=0L, options=0L)
参数----------Arguments----------
参数:mongo
(mongo) a mongo connection object.
(蒙戈)蒙戈的连接对象。
参数:ns
(string) namespace of the collection from which to find records.
(字符串)命名空间的集合,从中找到记录。
参数:query
(mongo.bson) The criteria with which to match the records to be found. The default of mongo.bson.empty() will cause the the very first record in the collection to be returned. Alternately, query may be a list which will be converted to a mongo.bson object by mongo.bson.from.list().
(mongo.bson)的标准进行匹配的记录被发现。默认情况下,的mongo.bson.empty()会返回集合中的第一个记录。或者,query可能是由mongo.bson.from.list()到mongo.bson对象的列表将被转换。
参数:sort
(mongo.bson) The desired fields by which to sort the returned records. The default of mongo.bson.empty() indicates that no special sorting is to be done; the records will come back in the order that indexes locate them. Alternately, sort may be a list which will be converted to a mongo.bson object by mongo.bson.from.list().
(mongo.bson)所需的字段进行排序返回的记录。默认情况下,的mongo.bson.empty()表示,没有什么特别的排序是必须要做的,记录会回来的顺序索引定位。或者,sort可能是由mongo.bson.from.list()到mongo.bson对象的列表将被转换。
参数:fields
(mongo.bson) The desired fields which are to be returned from the matching record. The default of mongo.bson.empty() will cause all fields of the matching record to be returned; however, specific fields may be specified to cut down on network traffic and memory overhead. Alternately, fields may be a list which will be converted to a mongo.bson object by mongo.bson.from.list().
(mongo.bson)所需的域,它是返回匹配的记录。默认情况下,的mongo.bson.empty()将导致所有要返回的字段匹配的记录,但是,可以指定特定领域,以减少网络流量和内存开销。或者,fields可能是由mongo.bson.from.list()到mongo.bson对象的列表将被转换。
参数:limit
(as.integer) The maximum number of records to be returned. A limit of 0L will return all matching records not skipped.
(as.integer)要返回的记录的最大数量。一个限制0L将返回所有匹配的记录不会被忽略。
参数:skip
(as.integer) The number of matching records to skip before returning subsequent matching records.
(as.integer)跳过后续匹配的记录,然后返回匹配的记录。
参数:options
(integer vector) Flags governing the requested operation as follows:
(整数向量)标志管理要求的操作如下:
mongo.find.cursor.tailable
mongo.find.cursor.tailable
mongo.find.slave.ok
mongo.find.slave.ok
mongo.find.oplog.replay
mongo.find.oplog.replay
mongo.find.no.cursor.timeout
mongo.find.no.cursor.timeout
mongo.find.await.data
mongo.find.await.data
mongo.find.exhaust
mongo.find.exhaust
mongo.find.partial.results </ul>
mongo.find.partial.results </ ul>
值----------Value----------
(mongo.cursor) An object of class "mongo.cursor" which is used to step through the matching records.
(mongo.cursor)一个对象的类的“mongo.cursor”使用步骤匹配的记录。
Note that an empty cursor will be returned if a database error occurred.<br> mongo.get.server.err() and mongo.get.server.err.string() may be examined in that case.
需要注意的是,如果数据库发生错误,将返回一个空指针。<BR> mongo.get.server.err()和mongo.get.server.err.string()在这种情况下,可以检查。
参见----------See Also----------
mongo.cursor,<br> mongo.cursor.next,<br> mongo.cursor.value,<br> mongo.find.one,<br> mongo.insert,<br> mongo.index.create,<br> mongo.update,<br> mongo.remove,<br> mongo,<br> mongo.bson.
mongo.cursor,参考mongo.cursor.next,参考mongo.cursor.value,参考mongo.find.one,参考mongo.insert,参考mongo.index.create ,参考mongo.update,参考mongo.remove,:参考蒙戈,参考mongo.bson。
实例----------Examples----------
mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "age", 18L)
query <- mongo.bson.from.buffer(buf)
# Find the first 100 records[前100条记录]
# in collection people of database test where age == 18[在收集的数据库测试的人== 18岁]
cursor <- mongo.find(mongo, "test.people", query, limit=100L)
# Step though the matching records and display them[虽然步骤匹配的记录,并显示它们]
while (mongo.cursor.next(cursor))
print(mongo.cursor.value(cursor))
mongo.cursor.destroy(cursor)
# shorthand: find all records where age=32, sorted by name, [速记找到的所有记录,年龄= 32,按名称排序,]
# and only return the name & address fields:[返回的名称和地址“字段:]
cursor <- mongo.find(mongo, "test.people", list(age=32),
list(name=1L), list(name=1L, address=1L))
}
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|