qiniu / qmgo

Qmgo - The Go driver for MongoDB. It‘s based on official mongo-go-driver but easier to use like Mgo.
Apache License 2.0
1.3k stars 153 forks source link

建议加个索引列出功能 #315

Open 888go opened 8 months ago

888go commented 8 months ago

我看了我们的, 没有取集合索引的功能. 其他人之前也在issues提过.

cupen commented 8 months ago

你是指这个功能? https://www.mongodb.com/docs/manual/reference/command/listIndexes/

有兴趣可以提个 PR. 参考官方 driver 的代码。 https://github.com/mongodb/mongo-go-driver/blob/f9ce69809fd84b5a6448a34d34b15975985333a1/mongo/index_view.go#L68-L150

个人以为提供一个 ListIndexes 接口,返回 []ops.IndexModel 就行。这个结果可以基于官方 driver 的这个结构体构建。

type IndexSpecification struct {
    // The index name.
    Name string

    // The namespace for the index. This is a string in the format "databaseName.collectionName".
    Namespace string

    // The keys specification document for the index.
    KeysDocument bson.Raw

    // The index version.
    Version int32

    // The length of time, in seconds, for documents to remain in the collection. The default value is 0, which means
    // that documents will remain in the collection until they're explicitly deleted or the collection is dropped.
    ExpireAfterSeconds *int32

    // If true, the index will only reference documents that contain the fields specified in the index. The default is
    // false.
    Sparse *bool

    // If true, the collection will not accept insertion or update of documents where the index key value matches an
    // existing value in the index. The default is false.
    Unique *bool

    // The clustered index.
    Clustered *bool
}
veronica-bytes commented 7 months ago

项目死了吗

888go commented 7 months ago

项目死了吗 没, 好好的, 另外词语干净点.

888go commented 7 months ago

项目死了吗 作者说稳定了, 也没什么好更新的. 所以不会经常更新, 如有bug一样在维护 .

cupen commented 7 months ago

@888go 抄家伙,跟他干! :D