fix collection

This commit is contained in:
kingecg 2025-06-07 23:07:29 +08:00
parent a07d62577c
commit 7cd56c342e
1 changed files with 7 additions and 10 deletions

View File

@ -2,15 +2,12 @@ package api
import ( import (
"sync" "sync"
)
import ( "git.pyer.club/kingecg/godocdb/document"
// "fmt" "git.pyer.club/kingecg/godocdb/index" // "fmt"
)
// "go.mongodb.org/mongo-driver/bson" // "go.mongodb.org/mongo-driver/bson"
"git.pyer.club/kingecg/godocdb/document"
"git.pyer.club/kingecg/godocdb/index"
)
// Collection MongoDB兼容的集合结构 // Collection MongoDB兼容的集合结构
type Collection struct { type Collection struct {
@ -46,10 +43,10 @@ func NewCollection(name string, storagePath string) (*Collection, error) {
// InsertOne 插入单个文档 // InsertOne 插入单个文档
func (coll *Collection) InsertOne(doc interface{}) error { func (coll *Collection) InsertOne(doc interface{}) error {
// 自动生成文档ID // 自动生成文档ID
docID := generateID() // docID := generateID()
// 将collection信息传递给文档管理层和索引管理层 // 将collection信息传递给文档管理层和索引管理层
if err := coll.documentStore.StoreDocument(coll.name, docID, doc); err != nil { if err := coll.documentStore.StoreDocument(coll.name, "", doc); err != nil {
return err return err
} }