我正在使用dump($value)
函数。我有一个关联数组,其中有很多条目。我需要立即查看这些值,而无需在转储时单击扩展按钮。我可以var_dump()
立即看到它,但我更喜欢使用 dump,因为它是现代且交互式的。下面是 dump 函数的快照:
我有这两个简单的集合:
项目:
{
"id" : "111",
"name" : "apple",
"status" : "active"
}
{
"id" : "222",
"name" : "banana",
"status" : "active"
}
Run Code Online (Sandbox Code Playgroud)
存货:
{
"item_id" : "111",
"qty" : 3,
"branch" : "main"
}
{
"item_id" : "222",
"qty" : 3
}
Run Code Online (Sandbox Code Playgroud)
现在我只想返回库存集合中存在且等于“main”且具有“status”==“active”和“branch”的项目。我有下面的代码,但它返回所有文档,第二个文档有一个空的“info”数组。
db.getCollection('items')
.aggregate([
{$match:{$and:[
{"status":'active'},
{"name":{$exists:true}}
]
}},
{$lookup:{
as:"info",
from:"inventory",
let:{fruitId:"$id"},
pipeline:[
{$match:{
$and:[
{$expr:{$eq:["$item_id","$$fruitId"]}},
{"branch":{$eq:"main"}},
{"branch":{$exists:true}}
]
}
}
]
}}
])
Run Code Online (Sandbox Code Playgroud)
谁能给我一个关于如何解决这个问题的想法?
我的 Slack 机器人无法向带有空格或类似“频道名称”的频道发送消息,但对于单字频道效果很好。
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://slack.com/api/chat.postMessage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{ \"channel\": \"channel-withspace\",\"text\": \"hello\"}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Authorization: Bearer <here>"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Run Code Online (Sandbox Code Playgroud)
这是错误:
{"ok":false,"error":"not_in_channel","warning":"missing_charset","response_metadata":{"warnings":["missing_charset"]}}
Run Code Online (Sandbox Code Playgroud)