我在mongoDB中使用聚合方法进行分组,但是当我使用$group它时,它返回了我用来分组的唯一字段。我已经尝试过了,$project但是也不起作用。我也试过了$first ,但效果很好,但是结果数据现在采用了不同的格式。
我需要的响应格式如下:
{
"_id" : ObjectId("5b814b2852d47e00514d6a09"),
"tags" : [],
"name" : "name here",
"rating" : "123456789"
}
Run Code Online (Sandbox Code Playgroud)
在我的query.response中添加$ group之后,_id的值将更改。(并且$ group仅接受_id,如果我尝试其他任何关键字,则会引发累加器错误。请也对此进行解释。)
{
"_id" :"name here" //the value of _id changed to the name field which i used in $group condition
}
Run Code Online (Sandbox Code Playgroud)
我必须删除名称字段中的重复项,而无需更改任何结构和字段。我也将nodeJS与猫鼬一起使用,因此请提供与其兼容的解决方案。
我已经使用 TouchableOpacity 作为我的提交按钮,当我点击提交按钮(TouchableOpacity)填写表单(登录/注册/...)后,键盘隐藏(如果打开),然后我需要再次按下提交按钮然后调用 onPress 方法。
我想要实现的是,如果我单击提交按钮,则无论键盘是否打开,都应调用 onPress() 方法。我必须单击两次才能提交看起来不太好的表单。
另外,我还没有在 IOS、android 上测试过这种行为。
编辑:1
登录屏幕代码 =>
<KeyboardAvoidingView>
<ScrollView>
<View style={styles.container}>
<View style={styles.container_one}>
<Image
style={{ height: 100, marginTop: 40 }}
source={require("../images/logo.png")}
/>
</View>
<View style={styles.container_three}>
<View>
<View style={styles.container_two}>
<Text style={styles.text_style_two}>Login</Text>
</View>
<View>
<Text style={styles.text_style_three}>
Please enter mobile number
</Text>
<TextInput
style={styles.text_input_1}
autoCapitalize="none"
keyboardType="numeric"
onChangeText={text => {
this.setState({
username: text
});
}}
value={this.state.username}
/>
</View>
<View>
<Text style={styles.text_style_three}>
Please enter your password
</Text>
<TextInput
style={styles.text_input_1}
secureTextEntry={true}
autoCapitalize="none"
onChangeText={text => {
this.setState({
password: text
}); …Run Code Online (Sandbox Code Playgroud) 我已经在 中设置了一些文本JTextArea。光标位于第 5 行。现在我想在第一行设置一些文本。
那么是否可以将光标重新定位到所需的行呢?