小编Ama*_*sal的帖子

Mongodb在创建新用户时收到错误

我刚刚在Ubuntu服务器上安装了一个新的mongodb,当我尝试adduser时,我收到错误

db.createUser(
  {
    user: "admin",
    pwd: "ADYkdfd332@@33",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)


2018-07-03T13:29:41.556+0530 E QUERY    [thread1] Error: couldn't add user: Use of SCRAM-SHA-256 requires undigested passwords :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1
Run Code Online (Sandbox Code Playgroud)

mongodb mongodb-query

10
推荐指数
4
解决办法
2万
查看次数

Mongoose 如何过滤填充字段

我有订单和用户,我想通过 Mongoose Populate 或其他方式按用户电话号码查找订单,我该怎么做?

Order (_id, item, user_id)
User (_id, email, phone)

const orders = await Order.find({}).populate({path: 'user', select: 'phone'})
Run Code Online (Sandbox Code Playgroud)

我想要类似的东西 (user.phone='xxxxxx') 我无法弄清楚。

mongoose mongodb mongodb-query mongoose-populate

6
推荐指数
2
解决办法
1万
查看次数

开发过程中每次都需要重新编译C++代码吗?

假设我们有一个庞大的代码库,并且我们正在使用 C++ 进行开发。我们是否每次都必须重新编译才能测试代码?

如果是的话,那么开发将需要很长时间。

这个问题的解决办法是什么?

c++ gcc g++ clang llvm-clang

3
推荐指数
1
解决办法
5736
查看次数

Golang Mongodb insertOne 返回空 ID ObjectID("000000000000000000000000")

我正在使用 Go 与 MongoDB 并创建一条新记录,但是当我将插入的 ID 转换为字符串时,它返回 ObjectID("000000000000000000000000")。

client := connect()
db := client.Database("godb")
// fmt.Println(db)

usersCollection := db.Collection("users")

result, err := usersCollection.InsertOne(ctx, bson.D{
    {Key: "title", Value: "The Polyglot Developer Podcast"},
    {Key: "author", Value: "Nic Raboy"},
})

if err != nil {
    log.Fatal(err)
}

newID := result.InsertedID
fmt.Println("InsertOne() newID:", newID)
fmt.Println("InsertOne() newID type:", reflect.TypeOf(newID))

oid, _ := newID.(primitive.ObjectID)
fmt.Println(oid)
Run Code Online (Sandbox Code Playgroud)

输出

InsertOne() newID: ObjectID("5e947e7036a5c1587fa4a06e")
InsertOne() newID type: primitive.ObjectID
ObjectID("000000000000000000000000")
Run Code Online (Sandbox Code Playgroud)

go google-app-engine-golang

1
推荐指数
1
解决办法
2137
查看次数