|
@@ -25,8 +25,23 @@ type (
|
|
}
|
|
}
|
|
)
|
|
)
|
|
|
|
|
|
-// NewBulkInserter returns a BulkInserter.
|
|
|
|
|
|
+// Deprecated. Use NewBatchInserter instead.
|
|
func NewBulkInserter(coll *mongo.Collection, interval ...time.Duration) *BulkInserter {
|
|
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{
|
|
inserter := &dbInserter{
|
|
collection: coll,
|
|
collection: coll,
|
|
}
|
|
}
|