From 7cd56c342e29bffbbba12e1ef08086af1298291c Mon Sep 17 00:00:00 2001 From: kingecg Date: Sat, 7 Jun 2025 23:07:29 +0800 Subject: [PATCH] fix collection --- api/collection.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/api/collection.go b/api/collection.go index a9e0e49..148cb35 100644 --- a/api/collection.go +++ b/api/collection.go @@ -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 }