Documentation ¶
Index ¶
- Constants
- Variables
- func Aggregate(tab string, pipeline any, results any) error
- func BulkWrite(tab string, models []mongo.WriteModel) (*mongo.BulkWriteResult, error)
- func Close() error
- func Count(tab string, filter any) (count int64, err error)
- func CreateIndex(tab string, keys []string) error
- func CreateTable(name string, opts *options.CreateCollectionOptions) error
- func Database() (*mongo.Database, error)
- func DeleteById(tab string, id primitive.ObjectID) (int64, error)
- func DeleteMany(tab string, filter any) (int64, error)
- func DeleteOne(tab string, filter any) (int64, error)
- func Distinct(tab string, filter any, field string) (values []any, err error)
- func DistinctId(tab string, filter any) (ids []primitive.ObjectID, err error)
- func Download(filename string) (*gridfs.DownloadStream, error)
- func DownloadById(id primitive.ObjectID) (*gridfs.DownloadStream, error)
- func DownloadTo(filename string, writer io.Writer) (int64, error)
- func DownloadToById(id primitive.ObjectID, writer io.Writer) (int64, error)
- func Drop(tab string) error
- func Find(tab string, filter any, sort any, skip int64, limit int64, results any) error
- func FindById(tab string, id primitive.ObjectID, result any) (has bool, err error)
- func FindFile(filter any, sort any, skip int32, limit int32, results any) error
- func FindOne(tab string, filter any, result any) (has bool, err error)
- func FindOneAndDelete(tab string, filter any, raw any) (has bool, err error)
- func FindOneAndReplace(tab string, filter any, replace any, raw any) (has bool, err error)
- func FindOneAndUpdate(tab string, filter any, update any, raw any) (has bool, err error)
- func InsertMany(tab string, docs []any) (ids []primitive.ObjectID, err error)
- func InsertOne(tab string, doc any) (id primitive.ObjectID, err error)
- func Open() error
- func ParseDocumentObjectId(doc any)
- func ParseObjectId(id any) (primitive.ObjectID, error)
- func Ping() error
- func Remove(id primitive.ObjectID) error
- func Rename(id primitive.ObjectID, filename string) error
- func ReplaceOne(tab string, filter any, result any, upsert bool) (int64, error)
- func StringifyDocumentObjectId(doc any)
- func StringifyObjectId(id any) (string, error)
- func Tables() ([]string, error)
- func UpdateById(tab string, id primitive.ObjectID, update any, upsert bool) (int64, error)
- func UpdateMany(tab string, filter any, update any, upsert bool) (int64, error)
- func UpdateOne(tab string, filter any, update any, upsert bool) (int64, error)
- func Upload(filename string, metadata any) (*gridfs.UploadStream, error)
- func UploadFrom(filename string, metadata any, reader io.Reader) (id primitive.ObjectID, err error)
- type Batch
- func (b *Batch) DeleteMany(filter any)
- func (b *Batch) DeleteOne(filter any)
- func (b *Batch) Flush() (*mongo.BulkWriteResult, error)
- func (b *Batch) InsertOne(doc any)
- func (b *Batch) UpdateMany(filter any, update any, upsert bool)
- func (b *Batch) UpdateOne(filter any, update any, upsert bool)
- func (b *Batch) Write(model mongo.WriteModel)
- type Document
Constants ¶
View Source
const MODULE = "mongodb"
Variables ¶
View Source
var ErrDisconnect = errors.New("数据库未连接")
Functions ¶
func BulkWrite ¶
func BulkWrite(tab string, models []mongo.WriteModel) (*mongo.BulkWriteResult, error)
func CreateIndex ¶
func CreateTable ¶
func CreateTable(name string, opts *options.CreateCollectionOptions) error
func DownloadById ¶
func DownloadById(id primitive.ObjectID) (*gridfs.DownloadStream, error)
func FindOneAndDelete ¶
func FindOneAndReplace ¶
func FindOneAndUpdate ¶
func ParseDocumentObjectId ¶
func ParseDocumentObjectId(doc any)
func StringifyDocumentObjectId ¶
func StringifyDocumentObjectId(doc any)
func StringifyObjectId ¶
func UpdateById ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.