如何更新评论?
评论模式:
<Button
android:id="@+id/forwardbtn"
android:layout_width="@dimen/joystick_mov_btn_size"
android:layout_height="@dimen/joystick_mov_btn_size"
android:layout_marginBottom="@dimen/joystick_mov_btn_size"
android:background="@drawable/arrow_btn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:rotation="270"/>
我有一个解决方案,但这不是最好的,正在寻找更好的解决方案
控制器:
comments: [
{
text: { type: String, trim: true, require: true },
created: { type: Date, default: Date.now },
commentedBy: { type: ObjectId, ref: "User" }
} ]
先拉出最后一条评论,然后用新评论替换!
我也使用了$ Set,但是它将整个注释数组替换为新来的!!
答案 0 :(得分:0)
db.bios.update(
{ _id: 1 },
{ $set: { 'contribs.1': 'ALGOL 58' } } //here contribs array with index 1 updating contribs[1]= 'ALGOL 58'\
)