我在mongodb中有大约200条记录。这些记录是基于人员信息的,而我提到的order
字段的信息要比获取记录的顺序要高,因此我假设一个{
"_id":1,
"name":"abcde1",
"lastname": "fkjg1",
"order":1,
"address":"street number 1231, New York"
}
{
"_id":2,
"name":"abc1",
"lastname": "fg1",
"order":2,
"address":"street number 133, New York"
}
字段是基于下面的示例的:-< / p>
{
"_id":2,
"name":"abc1",
"lastname": "fg1",
"order":1,
"address":"street number 133, New York"
}
{
"_id":1,
"name":"abcde1",
"lastname": "fkjg1",
"order":2,
"address":"street number 1231, New York"
}
一些用户希望像这样更新记录的方式,即记录的顺序将相同,但是记录将被更新,如下所示:-
func Update(){
blogId := blog.Id
blogErr := json.NewDecoder(c.Request.Body).Decode(&blog)
exists, _ := models.GetSingleBlogByID(blogId)
if exists == nil{
fmt.Println("There is no record")
return
}else{
if err := models.UpdateBlogById(blogId, blog); err == nil {
exists, _ := models.GetSingleBlogByID(blogId)
fmt.Println("Updated Success")
return
}else{
fmt.Println("Not Updated")
return
}
}
}
在上面的记录中,我将像这样更新记录,使顺序保持与过去相同,但其他字段将更新。因此,我将如何使用golang进行更新,我正在使用一个函数:-
ggplot(gapminder_82,
aes(gdpPercap, lifeExp, color = continent)) +
geom_point() +
scale_x_log10() +
scale_color_brewer(palette = "Set2") +
geom_smooth(method = "lm", se = F)
在执行此功能后,我需要做什么?