配置mongodb-c-driver,cmake后编译libbson出错

本人学生小白,想配置mongodb-c-driver,在官网上下了mongo-c-driver-1.1.6和cmake,按照教程用cmake先生成libbson的vs工程文件,然后用VS2012编译,结果报错了...
错误如下:
错误 52 error MSB3073: 命令“setlocal
"E:\Program Files (x86)\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd”已退出,代码为 1。 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets 134

我的环境是window 64位操作系统,VS2012
第一次提问,跪谢各位大神!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
mongodb版本2.6.5,mongodb-c-driver驱动用什么版本

之前用的是1.1.10,可以用最新的版本1.6.2吗。mongodb 2.6.5有没有对应最佳版本的c驱动

在mongodb-go-driver中通过子字符串正则表达式查询查找条目

<div class="post-text" itemprop="text"> <p>I can't get the official go mongo driver to successfully return objects that are queried via a regex query.</p> <p>I already know how to do it via the mongo shell and get my expected results. With this example i get all entries that contain "he" in their 'text' field:</p> <pre><code>db.getCollection('test').find({"text": /he/}) </code></pre> <p>same with this one:</p> <pre><code>db.getCollection('test').find({"text": {$regex: /he/, $options: ''}}) </code></pre> <p>This is my current code that doesn't work:</p> <pre><code>package main import ( "context" "fmt" "time" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) func main() { ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*time.Second)) defer cancel() client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017")) if err != nil { fmt.Println(err) return } err = client.Connect(ctx) if err != nil { fmt.Println(err) return } db := client.Database("test") coll := db.Collection("test") filter := bson.D{{"text", primitive.Regex{Pattern: "/he/", Options: ""}}} ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) defer cancel() cur, err := coll.Find(ctx, filter) if err != nil { fmt.Println(err) return } i := 0 for cur.Next(ctx) { i = i + 1 } fmt.Println("Found", i, "elements") } </code></pre> <p>Per <a href="https://github.com/mongodb/mongo-go-driver/blob/51421e413403fe3c9b0097147841f752421133e4/examples/documentation_examples/examples.go#L293" rel="nofollow noreferrer">example</a> in the official mongo-go-driver repository, this should work.</p> <p>My current entries in the collection just contain 2 fields, the id field and an extra text field. I currently have 3 entries. that look like this:</p> <pre><code>{ "_id" : ObjectId("5c9cc7e9950198ceeefecbdd"), "text" : "hello world" }, { "_id" : ObjectId("5c9cc7f6950198ceeefecbec"), "text" : "hello" }, { "_id" : ObjectId("5c9cc804950198ceeefecbfa"), "text" : "test world" } </code></pre> <p>My expected results with the code from above, should be the first 2 entries. Instead i get an empty cursor back. </p> <p>Does anybode know, what i am doing wrong? Thanks for your help.</p> </div>

Ubuntu18安装MongoDB报错,更新时报错。

Ubuntu18中安装MongoDB的时候不能更新存储,请问出现这样的情况该怎么解决? ``` lis@private-computer:~$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse lis@private-computer:~$ sudo apt install mongodb-org 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 下列软件包是自动安装的并且现在不需要了: libboost-program-options1.65.1 libgoogle-perftools4 libpcrecpp0v5 libsnappy1v5 libtcmalloc-minimal4 libyaml-cpp0.5v5 mongo-tools 使用'sudo apt autoremove'来卸载它(它们)。 将会同时安装下列软件: mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools 下列软件包将被【卸载】: mongodb-clients 下列【新】软件包将被安装: mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools 升级了 0 个软件包,新安装了 5 个软件包,要卸载 1 个软件包,有 37 个软件包未被升级。 需要下载 68.0 MB 的归档。 解压缩后会消耗 206 MB 的额外空间。 您希望继续执行吗? [Y/n] y 获取:1 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6/multiverse amd64 mongodb-org-shell amd64 3.6.9 [8,509 kB] 获取:2 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6/multiverse amd64 mongodb-org-server amd64 3.6.9 [15.1 MB] 获取:3 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6/multiverse amd64 mongodb-org-mongos amd64 3.6.9 [8,516 kB] 获取:4 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6/multiverse amd64 mongodb-org-tools amd64 3.6.9 [35.9 MB] 获取:5 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6/multiverse amd64 mongodb-org amd64 3.6.9 [3,518 B] 已下载 68.0 MB,耗时 7秒 (9,627 kB/s) (正在读取数据库 ... 系统当前共安装有 173903 个文件和目录。) 正在卸载 mongodb-clients (1:3.6.3-0ubuntu1) ... 正在选中未选择的软件包 mongodb-org-shell。 (正在读取数据库 ... 系统当前共安装有 173896 个文件和目录。) 正准备解包 .../mongodb-org-shell_3.6.9_amd64.deb ... 正在解包 mongodb-org-shell (3.6.9) ... 正在选中未选择的软件包 mongodb-org-server。 正准备解包 .../mongodb-org-server_3.6.9_amd64.deb ... 正在解包 mongodb-org-server (3.6.9) ... 正在选中未选择的软件包 mongodb-org-mongos。 正准备解包 .../mongodb-org-mongos_3.6.9_amd64.deb ... 正在解包 mongodb-org-mongos (3.6.9) ... 正在选中未选择的软件包 mongodb-org-tools。 正准备解包 .../mongodb-org-tools_3.6.9_amd64.deb ... 正在解包 mongodb-org-tools (3.6.9) ... dpkg: 处理归档 /var/cache/apt/archives/mongodb-org-tools_3.6.9_amd64.deb (--unpack)时出错: 正试图覆盖 /usr/bin/bsondump,它同时被包含于软件包 mongo-tools 3.6.3-0ubuntu1 dpkg-deb: 错误: 粘贴 subprocess was killed by signal (断开的管道) 正在选中未选择的软件包 mongodb-org。 正准备解包 .../mongodb-org_3.6.9_amd64.deb ... 正在解包 mongodb-org (3.6.9) ... 在处理时有错误发生: /var/cache/apt/archives/mongodb-org-tools_3.6.9_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) ```

MongoDB - Java | 使用MongoDB Java Driver连接到mongoLab

<div class="post-text" itemprop="text"> <p>I am implementing an android application that uses mongoDB database that is stored in mLab. The way i am connecting to the database is with code in my android application as follows:</p> <pre><code>private MongoCollection&lt;Document&gt; getCollectionn(String link, String coll){ //link is: mongodb://&lt;user&gt;:&lt;password&gt;@ds&lt;port&gt;.mlab.com:&lt;port&gt;/&lt;db&gt; MongoClientURI uri = new MongoClientURI(link); MongoClient client = new MongoClient(uri); MongoDatabase db = client.getDatabase(uri.getDatabase()); return db.getCollection(coll); } </code></pre> <p>I was wondering if this is the best way to connect with the database. I am reading that it has performance and security issues. Would it be better, for example, to connect with the database via a php file that is stored in a server and get the results from my queries from there and use them in my application. Is there some other way?</p> <p><strong>EDIT</strong></p> <p>From mongoLab documentation they are saying the following:</p> <p>mLab databases can be accessed by applications in two ways.</p> <p>The first method - the one <strong>we strongly recommend</strong> - is to connect using one of the available MongoDB drivers. You do not need to use our API if you use the driver. In fact, using a driver provides better performance, better security, and more functionality.</p> <p>The second method, documented in this article, is to connect via mLab’s RESTful Data API. Use this method only if you cannot connect using a MongoDB driver.</p> <p><a href="http://docs.mlab.com/data-api/#authentication" rel="nofollow">Here</a> is the documentation to their API. </p> <p>So why would someone suggest to use the RESTful API while mongoLab <strong>strongly</strong> recommends the mongo java driver? Is it because its about Android?</p> <p>Thanks!</p> </div>

mongodb-go-driver / bson结构转换为bson.Document编码

<div class="post-text" itemprop="text"> <p>I'm working with <a href="https://github.com/mongodb/mongo-go-driver" rel="nofollow noreferrer">https://github.com/mongodb/mongo-go-driver</a> and currently trying to implement a partial update of such struct</p> <pre><code>type NoteUpdate struct { ID string `json:"id,omitempty" bson:"_id,omitempty"` Title string `json:"title" bson:"title,omitempty"` Content string `json:"content" bson:"content,omitempty"` ChangedAt int64 `json:"changed_at" bson:"changed_at"` } </code></pre> <p>For instance, if I have</p> <pre><code>noteUpdate := NoteUpdate{ Title: "New Title" } </code></pre> <p>Then I expect that the only "title" field in the stored document will be changed.</p> <p>I need to write something like</p> <pre><code>collection.FindOneAndUpdate(context.Background(), bson.NewDocument(bson.EC.String("_id", noteUpdate.ID)), // I need to encode non-empty fields here bson.NewDocument(bson.EC.SubDocument("$set", bson.NewDocument(...))) ) </code></pre> <p>The problem is that I don't want to manually encode each non-empty field with <code>bson.EC.String(...)</code> or <code>bson.EC.Int64(...)</code>. I tried to use <code>bson.EC.InterfaceErr(...)</code> but got an error </p> <blockquote> <p>Cannot create element for type *models.NoteUpdate, try using bsoncodec.ConstructElementErr</p> </blockquote> <p>Unfortunately, there is no such function in bsoncodec. The only way I found is to create wrapper </p> <pre><code>type SetWrapper struct { Set interface{} `bson:"$set,omitempty"` } </code></pre> <p>And use it like</p> <pre><code>partialUpdate := &amp;NoteUpdate{ ID: "some-note-id", Title: "Some new title", } updateParam := SetWrapper{Set: partialUpdate} collection.FindOneAndUpdate( context.Background(), bson.NewDocument(bson.EC.String("_id", noteUpdate.ID)), updateParam, ) </code></pre> <p>It works, but is it possible to achieve the same with bson/bsoncodec document builders ?</p> <p>UPD. The full context of my question: I wrote the REST endpoint for <strong>partially</strong> updating "Note" documents(stored in MongoDB). Code that I have now:</p> <pre><code>var noteUpdate models.NoteUpdate ctx.BindJSON(&amp;noteUpdate) //omit validation and errors handling updateParams := services.SetWrapper{Set: noteUpdate} res := collection.FindOneAndUpdate( context.Background(), bson.NewDocument(bson.EC.String("_id", noteUpdate.ID)), updateParams, findopt.OptReturnDocument(option.After), ) </code></pre> <p>Code that I want to have</p> <pre><code>var noteUpdate models.NoteUpdate ctx.BindJSON(&amp;noteUpdate) //omit validation and errors handling res := collection.FindOneAndUpdate( context.Background(), bson.NewDocument(bson.EC.String("_id", noteUpdate.ID)), bson.NewDocument( //bsoncodec.ConstructElement doesn't exists bsoncodec.ConstructElement("$set", &amp;noteUpdate)), ), findopt.OptReturnDocument(option.After), ) </code></pre> <p>Code that I <strong>don't</strong> want to have</p> <pre><code>var noteUpdate models.NoteUpdate ctx.BindJSON(&amp;noteUpdate) //omit validation and errors handling bsonNote := bson.NewDocument() if noteUpdate.Title != "" { bsonNote.Append(bson.EC.String("title", noteUpdate.Title)) } if noteUpdate.Content != "" { bsonNote.Append(bson.EC.String("content", noteUpdate.Content)) } //..setting the rest of the fields... res := collection.FindOneAndUpdate( context.Background(), bson.NewDocument(bson.EC.String("_id", noteUpdate.ID)), bson.NewDocument(bson.EC.SubDocument("$set", bsonNote)), findopt.OptReturnDocument(option.After), ) </code></pre> <p>So, the precise question is - is there any way to build *bson.Document dynamically based on <code>bson</code> tags(without predefined wrappers like my SetWrapper)? </p> </div>

windows 上 MongoDB的C++driver编译报错

![图片说明](https://img-ask.csdn.net/upload/201712/26/1514279394_247972.png) 要把MongoDB c++driver编译成vc程序使用的库,scons编译的时候报错,错误文件居然是MongoDB官网下载的驱动里的文件 SConstruct, 求解。 版本: mongo-cxx-driver-legacy-1.1.2 boost\_1\_66\_0 python 3.6 scons 3.0

AuthenticationFailed:分片MongoDB上的用户文档中缺少MONGODB-CR凭据:无法连接到:queryrouter0.example.com:27017:

<div class="post-text" itemprop="text"> <p>I have a sharded MongoDB setup.</p> <p>I'm trying to connect to it from my Laravel application</p> <p>Before I sharded my database I was using <a href="https://github.com/jenssegers/laravel-mongodb" rel="nofollow noreferrer">laravel-mongodb</a> to connect to my regular mongodb instance.</p> <p>This was my previous config</p> <pre><code>'mongodb' =&gt; array( 'driver' =&gt; 'mongodb', 'host' =&gt; env('MONGODB_HOST', 'localhost'), 'port' =&gt; env('MONGODB_PORT', 27017), 'username' =&gt; env('MONGODB_USERNAME', ''), 'password' =&gt; env('MONGODB_PASSWORD', ''), 'database' =&gt; env('MONGODB_DATABASE', ''), 'options' =&gt; array( 'db' =&gt; env('MONGODB_AUTHDATABASE', '') //Sets the auth DB ) ) </code></pre> <p>I tried to update the <code>MONGODB_HOST</code> to the sharded query router hostname but I am now getting the error </p> <blockquote> <p>[MongoConnectionException] Failed to connect to: queryrouter0.example.com:27017: Authentication failed on database 'admin' with username 'maxrosecollins': auth failed`</p> </blockquote> <p>I can see in the logs on the <code>queryrouter0.example.com</code> server</p> <blockquote> <p>2017-09-05T14:42:36.558+0000 I NETWORK [thread2] connection accepted from 45.32.144.169:33086 #41615 (1 connection now open) 2017-09-05T14:42:36.560+0000 I ACCESS [conn41615] authenticate db: admin { authenticate: 1, user: "maxrosecollins", nonce: "xxx", key: "xxx" }</p> <p>2017-09-05T14:42:36.562+0000 I ACCESS [conn41615] Failed to authenticate maxrosecollins@admin with mechanism MONGODB-CR: AuthenticationFailed: MONGODB-CR credentials missing in the user document</p> <p>2017-09-05T14:42:36.563+0000 I - [conn41615] end connection 45.32.144.169:33086 (1 connection now open)</p> </blockquote> <p>I can connect to the query router using the following. This is on the same server I am getting the auth failed error when using laravel. I have double checked passwords and usernames</p> <pre><code>mongo queryrouter0.example.com:27017 -u "maxrosecollins" -p "password" --authenticationDatabase "admin" </code></pre> </div>

如何导入官方的mongodb驱动程序包

<div class="post-text" itemprop="text"> <p>How to import official mongoDB driver package in Go?</p> <p>I am following the official Go-mongoDB-driver package instruction (<a href="https://www.mongodb.com/blog/post/mongodb-go-driver-tutorial" rel="nofollow noreferrer">https://www.mongodb.com/blog/post/mongodb-go-driver-tutorial</a>). I have installed the mongoDB package using this:</p> <pre><code>go get github.com/mongodb/mongo-go-driver </code></pre> <p>but I just can't import the package</p> <p>I am doing a very simple snippet in my <code>main.go</code></p> <pre><code>package main import "github.com/mongodb/mongo-go-driver/mongo func main() { } </code></pre> <p>This gives me:</p> <pre><code>main.go:8:8: code in directory $GOPATH/src/github.com/mongodb/mongo-go-driver/bson expects import "go.mongodb.org/mongo-driver/bson" </code></pre> <p>When I tried to import <code>go.mongodb.org/mongo-driver/bson</code>, It gives me this:</p> <pre><code>main.go:10:8: cannot find package "go.mongodb.org/mongo-driver/bson" in any of: /usr/local/go/src/go.mongodb.org/mongo-driver/bson (from $GOROOT) $GOPATH/src/go.mongodb.org/mongo-driver/bson (from $GOPATH) </code></pre> <p>Kindly help, quite new in Go and not sure where to look since I don't find people having this issue a lot.</p> </div>

ubuntu14.04安装mongodb出现问题

我是安装官方教程安装: 1获取key: ``` sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 ``` 2添加: ``` echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list ``` 3 更新: ``` sudo apt-get update ``` 更新后我发现mongodb的那几个是“忽略” 4 安装: ``` sudo apt-get install -y mongodb-org ``` 提示: ``` E: 未发现软件包 mongodb-org ``` 我感觉是“apt-get update”日志那几个mongodb忽略的原因,不知道为什么会忽略,请问哪位老师遇到过此类问题,指点一下,谢谢。

如何使用mongodb / mongo-go-driver执行有效的分页

<div class="post-text" itemprop="text"> <p>I read in the following article that it is more efficient to use the natural ordering of <code>_id</code> to perform paging because skip always starts from the beginning from the collection</p> <p><a href="https://www.codementor.io/arpitbhayani/fast-and-efficient-pagination-in-mongodb-9095flbqr" rel="nofollow noreferrer">https://www.codementor.io/arpitbhayani/fast-and-efficient-pagination-in-mongodb-9095flbqr</a> </p> <pre><code>// Page 1 db.students.find().limit(10) // Page 2 last_id = ... # logic to get last_id db.students.find({'_id': {'$gt': last_id}}).limit(10) </code></pre> <p>But I have no idea how to perform the above using the <code>mongodb/mongo-go-driver</code>.</p> </div>

您如何使用官方的mongo-go-driver连接到MongoDB Atlas [重复]

<div class="post-text" itemprop="text"> <div class="question-status question-originals-of-duplicate"> <p>This question already has an answer here:</p> <ul> <li> <a href="/questions/52052311/how-to-use-new-url-from-mongodb-3-6-to-connect-from-golang" dir="ltr">How to use new URL from mongodb 3.6 to connect from golang</a> <span class="question-originals-answer-count"> 1 answer </span> </li> </ul> </div> <p>I'm looking at the <a href="https://www.mongodb.com/blog/post/mongodb-go-driver-tutorial-part-1-connecting-using-bson-and-crud-operations" rel="nofollow noreferrer">tutorial</a> offered in conjunction with the release of the official <a href="https://github.com/mongodb/mongo-go-driver" rel="nofollow noreferrer">mongo-go-driver</a> and the connection example uses a MongoDB server on <code>localhost</code></p> <pre><code>// Set client options clientOptions := options.Client().ApplyURI("mongodb://localhost:27017") </code></pre> <p>However, the new hosted MongoDB service <a href="https://www.mongodb.com/cloud/atlas" rel="nofollow noreferrer">Atlas</a> requires username and password to login. The connection string takes the format </p> <pre><code>mongodb://[username:password@]host1[/[database][?options]] </code></pre> <p>but there is no Golang example in the <a href="https://docs.atlas.mongodb.com/driver-connection/#driver-examples" rel="nofollow noreferrer">driver examples for Atlas</a>.</p> <p>So I'm wondering, what is the best way to log into Atlas without hard coding a password into a source file that will be posted on Github?</p> </div>

Mongodb-go-driver接口转换:interface {}是原始的.ObjectID,而不是原始的.ObjectID(来自不同包的类型)

<div class="post-text" itemprop="text"> <p>I can display the result.InsertedID with no problem, however, I keep getting the above error when I attempt to access the value to use it other places. I want to get the value before I leave the method that inserts the new object. The error message does not make any sense. </p> <p>I get this error with res.InsertedID.(primitive.ObjectID). What is the proper way?</p> <p>How do I get the concrete value preferably as a hex string? Even if I can get the value as a concrete ObjectID and not an interface I would be happy.</p> </div>

mongodb java driver连接失败不抛异常

mongodb java driver连接失败不抛异常 MongoClient mongoClient = new MongoClient(seeds,getConfOptions()); 我没启动mongodb服务,但是获取mongoClient的时候没有报任何异常,执行集合操作的时候也没有抛异常

我的maven项目连接mongodb出现链接异常

以前还好用,也插入过数据,但是今天就不行了。 项目是maven项目,连接的mongodb在远程服务器上,而且远程服务器的ip和我的ip不在一个网段内, 我改了ip和远程服务器在一个网段后,能ping通远程服务器,但是不能上网了。就出现了mongodb连接超时 具体异常如下 com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.1.0.jar:?] at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~[mongodb-driver-core-3.1.0.jar:?] at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:127) [mongodb-driver-core-3.1.0.jar:?] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_40] Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[?:1.8.0_40] at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[?:1.8.0_40] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) ~[?:1.8.0_40] at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:1.8.0_40] at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:1.8.0_40] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[?:1.8.0_40] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:1.8.0_40] at java.net.Socket.connect(Socket.java:589) ~[?:1.8.0_40] at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) ~[mongodb-driver-core-3.1.0.jar:?] at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.1.0.jar:?] ... 3 more

mongo-go-driver聚集调用始终返回错误

<div class="post-text" itemprop="text"> <p>I'm trying to do an aggregation with mongo-go-driver (MongoDB team driver for Golang) and I can't see what I'm doing wrong here: </p> <pre><code>// group group, e := bson.ParseExtJSONObject(` { "$group": { "_id":{ "ProductCode":"$ProductCode", "Dir":"$Dir", "WharehouseID":"$WharehouseID" } } } `) cursor, e := myCollection.Aggregate( context.Background(), group, ) // e output: "(Location40324) Unrecognized pipeline stage name: '_id'" </code></pre> <p>This is a mongodb error but if I execute this query in a mongodb native client I get the results and no error occurs. </p> </div>

去Dockerfile中的mongo-go-driver崩溃

<div class="post-text" itemprop="text"> <p>I have a little problem with my Go service. I'm new to Go and I just want to dockerize a little service that just connect to a mongodb instance.</p> <p>My code works fine locally. So here is my Dockerfile:</p> <pre><code># build stage FROM golang:alpine AS build-env RUN apk add --no-cache git ADD . . RUN go get -v -u go.mongodb.org/mongo-driver RUN go build -o mongotest # final stage FROM alpine WORKDIR /app COPY --from=build-env ./go/mongotest . RUN apk update &amp;&amp; apk add ca-certificates &amp;&amp; rm -rf /var/cache/apk/* EXPOSE 8000 CMD ["./mongotest"] </code></pre> <p>When I build it, I have this error message :</p> <pre class="lang-none prettyprint-override"><code>Step 6/18 : RUN go get -v -u go.mongodb.org/mongo-driver ---&gt; Running in 4c45c601800d Fetching https://go.mongodb.org/mongo-driver?go-get=1 Parsing meta tags from https://go.mongodb.org/mongo-driver?go-get=1 (status code 200) get "go.mongodb.org/mongo-driver": found meta tag get.metaImport{Prefix:"go.mongodb.org/mongo-driver", VCS:"git", RepoRoot:"https://github.com/mongodb/mongo-go-driver.git"} at https://go.mongodb.org/mongo-driver?go-get=1 go.mongodb.org/mongo-driver (download) package go.mongodb.org/mongo-driver: no Go files in /go/src/go.mongodb.org/mongo-driver The command '/bin/sh -c go get -v -u go.mongodb.org/mongo-driver' returned a non-zero code: 1 </code></pre> <p><code>no Go files in /go/src</code> ... ok, what can I do with that?</p> <p>The strange thing is that if I replace </p> <p><code>RUN go get -d -u go.mongodb.org/mongo-driver</code></p> <p>by </p> <p><code>RUN go get -d -u github.com/gorilla/mux</code></p> <p>it works!</p> <p>Is there a problem with mongo driver repo?</p> </div>

使用mgodb-go-driver将上载的文件存储在MongoDB GridFS中,而不保存到内存

<div class="post-text" itemprop="text"> <p>I am using below Go MongoDB plugin <a href="https://github.com/mongodb/mongo-go-driver/tree/master/mongo/gridfs" rel="nofollow noreferrer">MongoDB-GO-Driver</a> to store ymal file data.</p> <p>I am using <code>gridfs.NewBucket()</code> method.</p> <pre><code> func (s *FS) CreateFilewithBytes(data []byte, filename string) error { buf := bytes.NewBuffer(data) chunksize, _ := binary.ReadVarint(buf) _, err := gridfs.NewBucket(db, options.GridFSBucket(). SetName(filename). SetChunkSizeBytes(int32(chunksize)) if err != nil { return err } } </code></pre> <p>Please help me out how to store file and read file data.</p> </div>

通过mongo-go-driver连接mongodb会消耗大量内存

<div class="post-text" itemprop="text"> <p>I'm using mongo-go-driver, parallel connect several ports to check whether the port is listened by mongodb </p> <p>go version 1.12.3 mongo-go-driver v1.0</p> <pre class="lang-golang prettyprint-override"><code>type BaseServerStatus struct { Host string `bson:"host"` Version string `bson:"version"` Process string `bson:"process"` Pid int64 `bson:"pid"` Uptime int64 `bson:"uptime"` UptimeMillis int64 `bson:"uptimeMillis"` UptimeEstimate int64 `bson:"uptimeEstimate"` LocalTime time.Time `bson:"localTime"` } func GetBaseServerStatus(ip, port string) (srvStatus *BaseServerStatus, err error) { opts := options.Client() opts.SetDirect(true) opts.SetServerSelectionTimeout(1 * time.Second) opts.SetConnectTimeout(2 * time.Second) opts.SetSocketTimeout(2 * time.Second) opts.SetMaxConnIdleTime(1 * time.Second) opts.SetMaxPoolSize(1) url := fmt.Sprintf("mongodb://%s:%s/admin", ip, port) opts.ApplyURI(url) ctx, _ := context.WithTimeout(context.Background(), 2*time.Second) conn, err := mongo.Connect(ctx, opts) if err != nil { fmt.Printf("new %s:%s mongo connection error: %v ", ip, port, err) return } defer conn.Disconnect(ctx) err = conn.Ping(ctx, nil) if err != nil { fmt.Printf("ping %s:%s ping error: %v ", ip, port, err) return } sr := conn.Database("admin").RunCommand(ctx, bson.D{{"serverStatus", 1}}) if sr.Err() != nil { fmt.Printf("get %s:%s server status error: %v ", ip, port, sr.Err()) return } srvStatus = new(BaseServerStatus) err = sr.Decode(srvStatus) return } func main() { var wg sync.WaitGroup //ips := []string{"xxx.xxx.xxx.xxx:22"} ips := []string{"xxx.xxx.xxx.xxx:22", "xxx.xxx.xxx.xxx:80", "xxx.xxx.xxx.xxx:7005", "xxx.xxx.xxx.xxx:7017", "xxx.xxx.xxx.xxx:7006", "xxx.xxx.xxx.xxx:7016", "xxx.xxx.xxx.xxx:7018", "xxx.xxx.xxx.xxx:7014", "xxx.xxx.xxx.xxx:199", "xxx.xxx.xxx.xxx:8182", "xxx.xxx.xxx.xxx:7015", "xxx.xxx.xxx.xxx:7022", "xxx.xxx.xxx.xxx:7013", "xxx.xxx.xxx.xxx:7020", "xxx.xxx.xxx.xxx:9009", "xxx.xxx.xxx.xxx:7004", "xxx.xxx.xxx.xxx:7008", "xxx.xxx.xxx.xxx:7002", "xxx.xxx.xxx.xxx:7021", "xxx.xxx.xxx.xxx:7007", "xxx.xxx.xxx.xxx:7024", "xxx.xxx.xxx.xxx:7010", "xxx.xxx.xxx.xxx:7011", "xxx.xxx.xxx.xxx:7003", "xxx.xxx.xxx.xxx:7012", "xxx.xxx.xxx.xxx:7009", "xxx.xxx.xxx.xxx:7019", "xxx.xxx.xxx.xxx:8001", "xxx.xxx.xxx.xxx:7023", "xxx.xxx.xxx.xxx:111", "xxx.xxx.xxx.xxx:7001", "xxx.xxx.xxx.xxx:8002", "xxx.xxx.xxx.xxx:19313", "xxx.xxx.xxx.xxx:15772", "xxx.xxx.xxx.xxx:19777", "xxx.xxx.xxx.xxx:15778", "xxx.xxx.xxx.xxx:15776"} for _, ip := range ips { wg.Add(1) //time.Sleep(3 * time.Second) go func(addr string) { fmt.Printf("start to probe port %s ", addr) GetBaseServerStatus(strings.Split(addr, ":")[0], strings.Split(addr, ":")[1]) wg.Done() }(ip) } wg.Wait() fmt.Println("scan end") time.Sleep(20 * time.Second) } </code></pre> <p>however, run this code ,it consume 26GB memory I use pprof to diagnose, see below</p> <p>Showing top 10 nodes out of 15 flat flat% sum% cum cum% 26.29GB 96.86% 96.86% 26.29GB 96.86% go.mongodb.org/mongo-driver/x/network/connection.(*connection).ReadWireMessage</p> </div>

mongodb4.0在server 2008 x64安装问题

![server2008安装mongodb 4.0异常](https://img-ask.csdn.net/upload/201808/06/1533541173_365517.png) 各位大神麻烦请教一下,有没有人在server 2008 R2 x64系统上安装过win版mogodb,我在好几们电及上安装都出现,安装到如图界面后无法时行,卡死的情况,麻烦大神给支个招解决一下,谢谢! mongodb: mongodb-win32-x86_64-2008plus-ssl-4.0.1-signed.msi

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 java.io 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...

立即提问
相关内容推荐