MongoDB查询从文档中查找“where”帐单地址等于“交付地址”?
> db.demo589.insertOne({deliveryAddress:"US",billingAddress:"UK"});{
"acknowledged" : true, "insertedId" : ObjectId("5e92c117fd2d90c177b5bccc")
}
> db.demo589.insertOne({deliveryAddress:"US",billingAddress:"US"});{
"acknowledged" : true, "insertedId" : ObjectId("5e92c11bfd2d90c177b5bccd")
}
> db.demo589.insertOne({deliveryAddress:"US",billingAddress:"AUS"});{
"acknowledged" : true, "insertedId" : ObjectId("5e92c11ffd2d90c177b5bcce")
}
> db.demo589.insertOne({deliveryAddress:"UK",billingAddress:"US"});{
"acknowledged" : true, "insertedId" : ObjectId("5e92c127fd2d90c177b5bccf")
}在find()方法的帮助下显示集合中的所有文档-
> db.demo589.find();
这将产生以下输出-
{ "_id" : ObjectId("5e92c117fd2d90c177b5bccc"), "deliveryAddress" : "US", "billingAddress" : "UK" }
{ "_id" : ObjectId("5e92c11bfd2d90c177b5bccd"), "deliveryAddress" : "US", "billingAddress" : "US" }
{ "_id" : ObjectId("5e92c11ffd2d90c177b5bcce"), "deliveryAddress" : "US", "billingAddress" : "AUS" }
{ "_id" : ObjectId("5e92c127fd2d90c177b5bccf"), "deliveryAddress" : "UK", "billingAddress" : "US" }这是查询以检查“帐单地址等于交付地址”并获取文档-
> db.demo589.find( { $where: "this.deliveryAddress == this.billingAddress" } );这将产生以下输出-
{ "_id" : ObjectId("5e92c11bfd2d90c177b5bccd"), "deliveryAddress" : "US", "billingAddress" : "US" }热门推荐
3 哈尼族祝福语简短
9 天仓节祝福语简短
10 迎接新年祝福语简短霸气
11 生日祝福语简短致表哥
12 下午微信祝福语简短
13 毕业谢谢老师祝福语简短
14 新婚祝福语英语简短精辟
15 过年祝福语闺蜜简短
16 新年祝福语2026最简短
17 乔迁送茶具简短祝福语
18 医师考试祝福语毕业简短