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. net9:图片变成二进制流存入XML文档,从XML文档中读出图片以及从XML文档中读取并创建图片文件

    原文发布时间为:2008-08-10 -- 来源于本人的百度文章 [由搬家工具导入] fileToXml类: using System;using System.Data;using System.C ...

  2. class文件检查器

    Class文件检查器保证装载的class文件内容有正确的内部结构,并且这些class文件互相间协调一致.Class文件检查器实现的安全目标之一就是程序的健壮性.如果某个有漏洞的编译器,或某个聪明的黑客 ...

  3. 微信小程序踩坑之一[wx.request]请求模式

    最近在做小程序时,使用wx.request()方法请求时, 当使传输string类型时,一定要声明method请求模式为post,否则会一直报错,而不声明时默认为get, 已填坑 =,= wx.req ...

  4. CodeForces - 393E Yet Another Number Sequence

    Discription Everyone knows what the Fibonacci sequence is. This sequence can be defined by the recur ...

  5. layui-时间选择器-时间范围选择

    HTML: JS: layui.use(['laydate'],function{ }); start:就为你选择的开始日期; end:就为你选择的结束日期 此方式可选择任意范围的时间,时间格式可任意 ...

  6. linux下添加定时任务。

    这周要做一个定时增量更新Elasticsearch索引的功能,以前没有做过定时更新,所以请教了下同事,使用crontab添加linux下的定时任务. 一.linux下定时执行任务的方法 在linux中 ...

  7. SpringMVC整合MongoDB

    首先,在pom文件中新增spring-data-mongodb的依赖: <dependency> <groupId>org.springframework.data</g ...

  8. GDKOI賽前總結

    @(賽前總結)[GDKOI2017] 提一些比賽時要注意的事項: 賽前先把讀入優化/輸出優化的模板調試好, 加入缺省源中. 注意不要出錯, 輸出為0或者負數的情況要特盤; 讀入輸出文件名不要搞錯; 由 ...

  9. 在C++ 程序中调用被C 编译器编译后的函数,为什么要加extern “C”

    首先,作为extern是C/C++语言中表明函数和全局变量作用范围(可见性)的关键字,该关键字告诉编译器,其声明的函数和变量可以在本模块或其它模块中使用. 通常,在模块的头文件中对本模块提供给其它模块 ...

  10. 快讯 | FireEye在GitHub上开源密码破解工具GoCrack

    近日,FireEye 开源了一款密码破解工具 GoCrack,可在多机器上部署破解任务. GoCrack 是由 FireEye’s Innovation and Custom Engineering ...