feat: add batch inserter (#2755)
This commit is contained in:
@@ -25,8 +25,23 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// NewBulkInserter returns a BulkInserter.
|
||||
// Deprecated. Use NewBatchInserter instead.
|
||||
func NewBulkInserter(coll *mongo.Collection, interval ...time.Duration) *BulkInserter {
|
||||
return newBulkInserter(coll, interval...)
|
||||
}
|
||||
|
||||
// NewBatchInserter returns a BulkInserter.
|
||||
func NewBatchInserter(coll Collection, interval ...time.Duration) (*BulkInserter, error) {
|
||||
cloneColl, err := coll.Clone()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return newBulkInserter(cloneColl, interval...), nil
|
||||
}
|
||||
|
||||
// newBulkInserter returns a BulkInserter.
|
||||
func newBulkInserter(coll *mongo.Collection, interval ...time.Duration) *BulkInserter {
|
||||
inserter := &dbInserter{
|
||||
collection: coll,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user