有mongo对象
{
"_id" : ObjectId("5aa3abda9ff4d600da5b0168"),
"regionId" : NumberInt(3526),
"regionName" : "So Cal",
"categories" : [
"Other",
"Topicals",
"Tincture",
"Cannabis",
"Edibles",
"Extracts",
"Prerolled",
"Vape Cartridges"
]
}
网站对象就像这样
{ "regionId" : 3526,
"regionName" : "So Cal",
"categories" : [
"Other",
"Seeds",
"Tincture",
"Cannabis",
"Edibles",
"Extracts",
"Prerolled",
"Vape Cartridges"
]
}
最终对象应该是
{
"_id" : ObjectId("5aa3abda9ff4d600da5b0168"),
"regionId" : NumberInt(3526),
"regionName" : "So Cal",
"categories" : [
"Other",
"Seeds",
"Tincture",
"Cannabis",
"Edibles",
"Extracts",
"Prerolled",
"Vape Cartridges"
]
}
此对象来自网站,类别元素不断变化。 我想要实现的是,如果某个新元素出现在类别中,那么它应该插入我的mongo中,如果网站中没有某个元素,并且在我的mongo中,它应该从我的mongo对象中删除。
$ addToSet只会解决问题,如果添加了一些新元素但是删除了什么?
(我是一个绝对的初学者)在mongo请建议如何实现这一目标。
答案 0 :(得分:0)
const detailsOfCurrentNotes = [...data.notes];
命令可以解决此问题
const By = selenium.By;
driver.findElement(By.xpath("/html/body/div/a[1]")).click();
const firstName = driver.findElement(By.id("firstName"));
firstName.sendKeys("Jon");
const lastName = driver.findElement(By.id("lastName"));
lastName.sendKeys("Smith");