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 (
|
||||
"context"
|
||||
"fmt"
|
||||
"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/proto/sdkws"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"strconv"
|
||||
"sync"
|
||||
@ -36,19 +34,18 @@ func Test_BatchInsertChat2DB(t *testing.T) {
|
||||
db := &commonMsgDatabase{
|
||||
msgDocDatabase: unrelation.NewMsgMongoDriver(mongo.GetDatabase()),
|
||||
}
|
||||
ctx := context.Background()
|
||||
|
||||
msgs := make([]*sdkws.MsgData, 0, 1)
|
||||
for i := 0; i < cap(msgs); i++ {
|
||||
msgs = append(msgs, &sdkws.MsgData{
|
||||
Content: []byte(fmt.Sprintf("test-%d", i)),
|
||||
SendTime: time.Now().UnixMilli(),
|
||||
})
|
||||
}
|
||||
err = db.BatchInsertChat2DB(ctx, "test", msgs, 0)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
//ctx := context.Background()
|
||||
//msgs := make([]*sdkws.MsgData, 0, 1)
|
||||
//for i := 0; i < cap(msgs); i++ {
|
||||
// msgs = append(msgs, &sdkws.MsgData{
|
||||
// Content: []byte(fmt.Sprintf("test-%d", i)),
|
||||
// SendTime: time.Now().UnixMilli(),
|
||||
// })
|
||||
//}
|
||||
//err = db.BatchInsertChat2DB(ctx, "test", msgs, 0)
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
|
||||
_ = db.BatchInsertChat2DB
|
||||
c := mongo.GetDatabase().Collection("msg")
|
||||
|
Loading…
x
Reference in New Issue
Block a user