fix collection
This commit is contained in:
parent
a07d62577c
commit
7cd56c342e
|
@ -2,16 +2,13 @@ package api
|
|||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
import (
|
||||
// "fmt"
|
||||
|
||||
// "go.mongodb.org/mongo-driver/bson"
|
||||
"git.pyer.club/kingecg/godocdb/document"
|
||||
"git.pyer.club/kingecg/godocdb/index"
|
||||
"git.pyer.club/kingecg/godocdb/index" // "fmt"
|
||||
)
|
||||
|
||||
// "go.mongodb.org/mongo-driver/bson"
|
||||
|
||||
// Collection MongoDB兼容的集合结构
|
||||
type Collection struct {
|
||||
name string
|
||||
|
@ -20,8 +17,8 @@ type Collection struct {
|
|||
}
|
||||
|
||||
var (
|
||||
indexStores = make(map[string]*index.IndexStore)
|
||||
indexStoreMu sync.RWMutex
|
||||
indexStores = make(map[string]*index.IndexStore)
|
||||
indexStoreMu sync.RWMutex
|
||||
)
|
||||
|
||||
// NewCollection 创建新的集合实例
|
||||
|
@ -46,10 +43,10 @@ func NewCollection(name string, storagePath string) (*Collection, error) {
|
|||
// InsertOne 插入单个文档
|
||||
func (coll *Collection) InsertOne(doc interface{}) error {
|
||||
// 自动生成文档ID
|
||||
docID := generateID()
|
||||
// docID := generateID()
|
||||
|
||||
// 将collection信息传递给文档管理层和索引管理层
|
||||
if err := coll.documentStore.StoreDocument(coll.name, docID, doc); err != nil {
|
||||
if err := coll.documentStore.StoreDocument(coll.name, "", doc); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue