SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
filer mongo add func create index unique directory, name
buktonda37455254ee
diff --git a/weed/filer2/mongodb/mongodb_store.go b/weed/filer2/mongodb/mongodb_store.goindex 4e78c54a4d..aa55145d76 100644--- a/weed/filer2/mongodb/mongodb_store.go+++ b/weed/filer2/mongodb/mongodb_store.go@@ -10,6 +10,7 @@ import ("go.mongodb.org/mongo-driver/bson""go.mongodb.org/mongo-driver/mongo""go.mongodb.org/mongo-driver/mongo/options"+ "go.mongodb.org/mongo-driver/x/bsonx""time")@@ -49,10 +50,37 @@ func (store *MongodbStore) connection(uri string, poolSize uint64) (err error) {}client, err := mongo.Connect(ctx, opts)+ if err != nil {+ return err+ }++ c := client.Database(store.database).Collection(store.collectionName)+ err = store.indexUnique(c)store.connect = clientreturn err}+func (store *MongodbStore) createIndex (c *mongo.Collection, index mongo.IndexModel, opts *options.CreateIndexesOptions) error {+ _, err := c.Indexes().CreateOne(context.Background(), index, opts)+ return err+}++func (store *MongodbStore) indexUnique(c *mongo.Collection) error {+ opts := options.CreateIndexes().SetMaxTime(10 * time.Second)++ unique := new(bool)+ *unique = true++ index := mongo.IndexModel{+ Keys: bsonx.Doc{{Key: "directory", Value: bsonx.Int32(1)}, {Key: "name", Value: bsonx.Int32(1)}},+ Options: &options.IndexOptions{+ Unique: unique,+ },+ }++ return store.createIndex(c, index, opts)+}+func (store *MongodbStore) BeginTransaction(ctx context.Context) (context.Context, error) {return ctx, nil}