这是来自mongoDB集合的样本文档:-
type MyQueryParam name a = QueryParam' '[Optional, Lenient]
类别数组包含该位置所属的所有类别ID。
{
"place_id" : "57222c6f498e78e3bfe0a575",
"title_AR" : "University Institute Hall",
"title_EN" : "University Institute Hall",
"description_AR" : "",
"description_EN" : "",
"best_photo" : "https://igx.4sqi.net/img/general/250x250/8862268_8oi3vr81Zm3ucytWjoSyvWXXS-7BUpNxKgyJvj0Lusc.jpg",
"city_AR" : "Kolkata",
"city_EN" : "Kolkata",
"state_AR" : "West Bengal",
"state_EN" : "West Bengal",
"country" : "IN",
"postal_code_AR" : "700073",
"postal_code_EN" : "700073",
"location_AR" : "7, Bankim Chatterjee St, Kolkata 700073, West Bengal, India",
"location_EN" : "7, Bankim Chatterjee St, Kolkata 700073, West Bengal, India",
"latitude" : 22.5744745110906,
"longitude" : 88.3630291046031,
"loc" : {
"type" : "Point",
"coordinates" : [
88.3630291046031,
22.5744745110906
]
},
"website" : "",
"email" : "",
"contact_number_AR" : "+913322416214",
"contact_number_EN" : "+913322416214",
"ratings_AR" : "",
"ratings_EN" : "",
"no_of_comments_AR" : 0,
"no_of_comments_EN" : 0,
"categories" : "4d4b7104d754a06370d81259,5032792091d4c4b30a586d5c,4d4b7104d754a06370d81259,5032792091d4c4b30a586d5c",
"category_array" : [
"4d4b7104d754a06370d81259",
"5032792091d4c4b30a586d5c",
"4d4b7104d754a06370d81259",
"5032792091d4c4b30a586d5c"
],
"created_date" : "2018-05-31 16:39:33",
"modified_date" : "2018-05-31 16:39:33",
"photo_saved" : 0,
"tip_saved" : 0,
"updated_at" : ISODate("2018-05-31T11:09:33.000Z"),
"created_at" : ISODate("2018-05-31T11:09:33.000Z")
}
我想根据位置和类别获取地点。这是我的脚本:-
"category_array" : [
"4d4b7104d754a06370d81259",
"5032792091d4c4b30a586d5c",
"4d4b7104d754a06370d81259",
"5032792091d4c4b30a586d5c"
]
现在是问题所在。根据{{3}}:-
要进行精确的数组匹配,包括元素的顺序:-
db.runCommand(
{
geoNear: "foursquare_places",
near: { type: "Point", coordinates: [ 88.363892, 22.572645 ] },
spherical: true,
query: { category_array: { $all: ["5032792091d4c4b30a586d5c"] }},
maxDistance: 500
}
)
要查找一个包含元素“ red”和“ blank”的数组,而不考虑顺序或该数组中的其他元素:-
db.inventory.find( { tags: ["red", "blank"] } )
以下示例查询所有文档,其中tag是一个包含字符串“ red”作为其元素之一的数组
db.inventory.find( { tags: { $all: ["red", "blank"] } } )
要提取其category_array包含以下数组的一个或所有元素的所有记录的查询是什么?
db.inventory.find( { tags: "red" } )
答案 0 :(得分:1)
“一个或全部”对我来说毫无意义。假设它是“至少之一”,则需要使用$in:
UITextField
将返回@objc func hideTextField(_ sender: UIButton) {
if let field = sender.superview?.superview as? UITextField, !field.isHidden {
UIView.animate(withDuration: 0.2) {
field.text = ""
field.isHidden = true
}
}
}
至少具有3个字符串之一的所有文档。