1 回答

TA贡献1735条经验 获得超5个赞
doc.DataTo(&b)该程序仅在返回错误时将博客附加到结果中。
编写如下代码:
var bs models.Blogs
iter := client.Collection("blogs").Documents(ctx)
defer iter.Stop() // add this line to ensure resources cleaned up
for {
doc, err := iter.Next()
if err == iterator.Done {
break
}
if err != nil {
// Handle error, possibly by returning the error
// to the caller. Break the loop or return.
... add code here
}
var b models.Blog
if err := doc.DataTo(&b); err != nil {
// Handle error, possibly by returning the error
// to the caller. Continue the loop,
// break the loop or return.
... add code here
}
bs = append(bs, b)
}
- 1 回答
- 0 关注
- 123 浏览
添加回答
举报