src/github.com/mongodb/mongo-go-driver/mongo/cursor.go

// Copyright (C) MongoDB, Inc. 2017-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 package mongo import (
"context" "github.com/mongodb/mongo-go-driver/bson"
) // Cursor instances iterate a stream of documents. Each document is
// decoded into the result according to the rules of the bson package.
//
// A typical usage of the Cursor interface would be:
//
// var cur Cursor
// ctx := context.Background()
// defer cur.Close(ctx)
//
// for cur.Next(ctx) {
// elem := bson.NewDocument()
// if err := cur.Decode(elem); err != nil {
// log.Fatal(err)
// }
//
// // do something with elem....
// }
//
// if err := cur.Err(); err != nil {
// log.Fatal(err)
// }
//
type Cursor interface {
// NOTE: Whenever ops.Cursor changes, this must be changed to match it. // Get the ID of the cursor.
ID() int64 // Get the next result from the cursor.
// Returns true if there were no errors and there is a next result.
Next(context.Context) bool Decode(interface{}) error DecodeBytes() (bson.Reader, error) // Returns the error status of the cursor
Err() error // Close the cursor.
Close(context.Context) error
}

src/github.com/mongodb/mongo-go-driver/mongo/cursor.go 游标的简洁实用的更多相关文章

  1. MongoDB - Introduction of the mongo Shell

    Introduction The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mong ...

  2. MongoDB源码分析——mongo与JavaScript交互

    mongo与JavaScript交互 源码版本为MongoDB 2.6分支     之前已经说过mongo是MongoDB提供的一个执行JavaScript脚本的客户端工具,执行js其实就是一个js和 ...

  3. MongoDB源码分析——mongo主程序入口分析

    Edit   源码版本为MongoDB 2.6分支 mongo主程序入口分析 mongo是MongoDB提供的一个执行JavaScript脚本的客户端工具,可以用来和服务端交互,2.6版本的Mongo ...

  4. 插入MongoDB文档:mongo控制台查看插入到MongoDB文档中的内容

    const MongoClient = require('mongodb').MongoClient; const assert = require('assert'); const url = 'm ...

  5. mongodb学习之:mongo安装以及远程访问

    在linux下通过apt-get install mongo的方式一键式安装mongo 安装后mongo的配置文件位于/etc/mongodb.conf. 里面有mongo的各项配置,文件内容如下:重 ...

  6. Mongodb Compile C++ Driver

    之前发现直接编译mongo源码中的驱动,静态库的驱动会很大,在链接使用的时候会报很多链接错误. 转而直接编译单独提供驱动源码,同样vc2008的版本也要做我的另一篇博文中修改,在这不多说,具体参见: ...

  7. MongoDB数据库CXX Driver编译

    最近项目需要,想要测试下MongoDB读写大量小图片的速度(单纯文件系统io效率比较低,想试试NoSQL能不能提速), 因为使用C++开发,所以使用MongoDB的CXX驱动,需要自己编译,下面记录整 ...

  8. mongodb MongoDB C#/.NET driver version

    The first column lists the driver version(s). C#/.NET Driver Version MongoDB 2.6 MongoDB 3.0 MongoDB ...

  9. ubuntu mongodb报错:mongo - couldn't connect to server 127.0.0.1:27017

    在进入mongo的时候,出现在下面错误信息.那如何解决呢? 标记一下,以便下次理碰的到时候,有个参考. warning: Failed to connect to 127.0.0.1:27017, r ...

随机推荐

  1. transform与position:fixed的那些恩怨--摘抄

    1. 前言 在写这篇文章之前,我理解的fixed元素是这样的:(摘自CSS布局基础) 固定定位与absolute定位类型类似,但它的相对移动的坐标是视图(屏幕内的网页窗口)本身.由于视图本身是固定的, ...

  2. VS2010 + winxp 无法定位程序输入点GetTickCount64 在动态链接库kernel32.dll上 错误

    winxp系统,使用VS2010, 在使用boost中的thread中的sleep的时候出现 “无法定位程序输入点GetTickCount64 在动态链接库kernel32.dll上”的错误, 在网上 ...

  3. LeetCode OJ--Subsets II

    https://oj.leetcode.com/problems/subsets-ii/ 求一个集合的子集,但集合中有重复元素. 求子集的问题,对应着数的二进制,相当于对二进制的一个遍历. #incl ...

  4. AC日记——[SCOI2010]游戏 bzoj 1854

    1854: [Scoi2010]游戏 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 4938  Solved: 1948[Submit][Status] ...

  5. ros pub sub ("~")

    base_velocity_smoother.cpp                        remap ("~")    订阅: "cmd_vel"   ...

  6. Java创建和解析Json数据方法(四)——json-lib包的使用

    (四)json-lib包的使用         既然json-lib包比org.json包重量级,那么json-lib包肯定有很多org.json包没有的类和方法,这篇笔记简单记录json-lib包中 ...

  7. chm 转 pdf 工具推荐与对比

    在进行推荐chm转pdf的软件之前,首先来了解一下为什么我们要将chm转为pdf. CHM是英语“Compiled Help Manual”的简写,即“已编译的帮助文件”.CHM是微软新一代的帮助文件 ...

  8. C# 获取COM对象 ProgId ClsId

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/fe262fdd-a93f-427e-8771-2c64e7ac3064/getting- ...

  9. 赞一下TMS Software 和 AdvStringGrid

    非常久前给Support发Email问能不能在设计期给AdvStringGrid标题加个数字标识.每次我都是自己改代码加上去.这次升级到新版本号,没想到增加了这个功能: 功能虽小可是非常有用,非常多的 ...

  10. Html5学习笔记1 元素 标签 属性

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...