最新版的mongo client的更新了
来源:5-6 Find查询记录
慕函数7881054
2019-01-31
最新版的mongo client的更新了
if cursor,err=collection.Find(context.TODO(),cond,&options.FindOptions{
Skip:new(int64),
Limit:func() int64 { i := int64(2); return &i }(),
}); err != nil {
fmt.Println(err)
return
}
参数类型改为了 options.FindOptions Skip和Limit 都是int64类型 传参比较麻烦 不知道为什么要这么改。
写回答
2回答
-
SuperDi
2022-01-13
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) findOptions := options.Find() findOptions.SetSkip(0) findOptions.SetLimit(2) cursor, err := collection.Find(ctx, bson.D{{"jobName", "job100"}}, findOptions)应该先定义好findOptions,通过调用函数设置好参数,再引用
10 -
小鱼儿老师
2019-02-12
同学好,SDK变化无法控制,我们掌握思路即可。
00
相似问题