为了账号安全,请及时绑定邮箱和手机立即绑定

创建索引会导致未经授权的错误

创建索引会导致未经授权的错误

Go
慕沐林林 2022-09-19 14:56:51
有用于此目的的 和 命令。argslocals例如,对于这个(无意义的)示例代码:package mainimport "fmt"func example(a, b int) (c int) {  d := a + b  if true {    e := d + 123    c = e + 1    fmt.Println("time for a breakpoint")  }  return c}func main() {  example(2, 3)}当停止在 print 语句处时,输出如下所示:(dlv) argsa = 2b = 3c = 129(dlv) localsd = 5e = 128有关可用命令的更多详细信息,请参阅 Delve 的 cli/README.md。
查看完整描述

1 回答

?
catspeake

TA贡献1111条经验 获得超0个赞

我已经联系了微软的支持,这是他们的回复:

这是对具有时间点还原的帐户的限制。必须使用唯一索引创建集合。

https://docs.microsoft.com/en-us/azure/cosmos-db/continuous-backup-restore-introduction

您可以使用这样的命令创建具有已存在的唯一索引的集合(从Mongo外壳,或Robo3T或其他客户端)

用于管理 Azure Cosmos DB 的 MongoDB API 中数据的 MongoDB 扩展命令|微软文档

例如:

db.runCommand({

  customAction: "CreateCollection",

  collection: "my_collection",

  shardKey: "my_shard_key",

  offerThroughput: 100,

  indexes: [{key: {_id: 1}, name: "_id_1"}, {key: {a: 1, b: 1}, name:"a_1_b_1", unique: true} ]

})

所以现在我的代码看起来像这样:


func Collection(db *mongo.Database, c string, indices []bson.M) *mongo.Collection {

    ctx, cls := context.WithTimeout(context.Background(), time.Second * 15)

    defer cls()


    if cursor, _ := db.ListCollectionNames(ctx, bson.M{"name": c}); len(cursor) < 1 {

        cmd := bson.D{{"customAction", "CreateCollection"}, {"collection", c}}

        if indices != nil {

            cmd = append(cmd, bson.E{Key: "indexes", Value: indices})

        }


        res := db.RunCommand(ctx, cmd)


        if res.Err() != nil {

            log.Fatal(res.Err())

        }

    }


    return db.Collection(c)

}


查看完整回答
反对 回复 2022-09-19
  • 1 回答
  • 0 关注
  • 67 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信