INNER CODE UNIT · Go

NewCollection

chenmingyong0423/go-mongox · collection.go:28

func NewCollection[T any](db *Database, collection string) *Collection[T] {
	return &Collection[T]{
		db:         db,
		collection: db.Database().Collection(collection),
		callbacks:  db.callbacks,
		fields:     field.ParseFields(new(T)),
	}
}

type Collection[T any] struct {
	db         *Database
	collection *mongo.Collection
	// callbacks inherited from database
	callbacks *callback.Callback

	fields []*field.Filed
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…