Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ghost opened this issue Feb 23, 2024 · 5 comments
Open

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

ghost opened this issue Feb 23, 2024 · 5 comments
Labels
feature new feature

Comments

@ghost
Copy link

ghost commented Feb 23, 2024

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

@cupen
Copy link

cupen commented Feb 29, 2024

你是指这个功能?
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
Copy link

项目死了吗

@ghost
Copy link
Author

ghost commented Mar 9, 2024

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

@ghost
Copy link
Author

ghost commented Mar 9, 2024

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

@cupen
Copy link

cupen commented Mar 9, 2024

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

@jiangz222 jiangz222 added the feature new feature label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new feature
Projects
None yet
Development

No branches or pull requests

3 participants