亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

創建索引會導致未經授權的錯誤

創建索引會導致未經授權的錯誤

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 關注
  • 99 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號