我使用查询如:
public void onBtnClick(View view) {
if (view.getId() == R.id.imageRecBtn) {
//New code lines BEGIN***************************************************************************************************
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//checking the permission status
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) !=
PackageManager.PERMISSION_GRANTED) {
//request the permission
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.RECORD_AUDIO},
REQUEST_CODE_RECORD_AUDIO);
} else {
promptSpeechInput();
}
}
//New code lines END***************************************************************************************************
}
}
返回输出,例如:
db.users.find({}).projection({"_id":0,"email":1,"name.fullName":1})
我正在尝试将此类对象转换为:
{
"email" : "foo@example.bar",
"name" : {
"fullName" : "Foo Bar"
}
}
答案 0 :(得分:3)
您必须使用$project
聚合阶段,该阶段采用键和值(作为表达式)来转换输出。
db.users.aggregate({$project:{"_id":0,"email":1,"name":"$name.fullName"}