mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Test_BatchInsertChat2DB
This commit is contained in:
parent
95cf1e292b
commit
1d22b44dd4
@ -2,10 +2,8 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
@ -36,19 +34,18 @@ func Test_BatchInsertChat2DB(t *testing.T) {
|
|||||||
db := &commonMsgDatabase{
|
db := &commonMsgDatabase{
|
||||||
msgDocDatabase: unrelation.NewMsgMongoDriver(mongo.GetDatabase()),
|
msgDocDatabase: unrelation.NewMsgMongoDriver(mongo.GetDatabase()),
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
//ctx := context.Background()
|
||||||
|
//msgs := make([]*sdkws.MsgData, 0, 1)
|
||||||
msgs := make([]*sdkws.MsgData, 0, 1)
|
//for i := 0; i < cap(msgs); i++ {
|
||||||
for i := 0; i < cap(msgs); i++ {
|
// msgs = append(msgs, &sdkws.MsgData{
|
||||||
msgs = append(msgs, &sdkws.MsgData{
|
// Content: []byte(fmt.Sprintf("test-%d", i)),
|
||||||
Content: []byte(fmt.Sprintf("test-%d", i)),
|
// SendTime: time.Now().UnixMilli(),
|
||||||
SendTime: time.Now().UnixMilli(),
|
// })
|
||||||
})
|
//}
|
||||||
}
|
//err = db.BatchInsertChat2DB(ctx, "test", msgs, 0)
|
||||||
err = db.BatchInsertChat2DB(ctx, "test", msgs, 0)
|
//if err != nil {
|
||||||
if err != nil {
|
// panic(err)
|
||||||
panic(err)
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
_ = db.BatchInsertChat2DB
|
_ = db.BatchInsertChat2DB
|
||||||
c := mongo.GetDatabase().Collection("msg")
|
c := mongo.GetDatabase().Collection("msg")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user