我正在创建一个 Nest.js 应用程序,并希望考虑该应用程序的可扩展性。我发现基本上有两种扩展方法:集群或工作线程。我已经在这里询问了有关 Node.js 应用程序的可扩展性的问题Docker vs Cluster with Node.js。并发现最好用 docker 包装应用程序并从中创建克隆,而不是集群。所以,我已经使用 Nest.js 应用程序做到了这一点,但问题是:
对于以下文档,我想更新数组中status特定消息messages的:
[{
"_id" : ObjectId("6079bab4f297df39a44609cb"),
"title" : "Test messages of single user",
"messages" : [
{
"_id" : ObjectId("6079bab4f297df39a44609cc"),
"body" : "Test 1",
"status" : 1
},
{
"_id" : ObjectId("6079bab4f297df39a44609cd"),
"body" : "Test 2",
"status" : 1
},
{
"_id" : ObjectId("6079bcf7c041b00ec4cebb9d"),
"body" : "Hello I'm Sam",
"status" : 1
}
]
}]
Run Code Online (Sandbox Code Playgroud)
在这里运行下面的查询
db.update(
{
"_id": ObjectId("6079bab4f297df39a44609cb"),
"messages": { $elemMatch: { _id: ObjectId("6079bcf7c041b00ec4cebb9d") } }
}, …Run Code Online (Sandbox Code Playgroud) 我在手风琴中递归地调用组件以显示树状结构。
该代码适用于短输入,但在嵌套数据的递归调用上滞后
它就像一棵 json 树。
//sample.component.html
<app-tree [input]="data"></app-tree>
//tree.component.html
<mat-accordion>
<mat-expansion-panel hideToggle="true" (click)="toggleTree($event, input)">
<mat-expansion-panel-header>
<mat-panel-title>
<mat-icon>{{input.buttonName}}</mat-icon>
{{input.key}}
</mat-panel-title>
</mat-expansion-panel-header>
<ul class="main-obj"> // tried *ngIf here
<div class="obj-list" *ngFor="let item of input.value; trackBy: trackChanges">
<li>
{{item.key}}: {{item.value}}
</li>
<li style="list-style: none; margin-left: -40px;">
<app-tree [input]="item"></app-tree>
</li>
</div>
</ul>
</mat-expansion-panel>
</mat-accordion>
//tree.component.ts
import { Component, OnInit, Input, Output } from '@angular/core';
import { EventEmitter } from 'events';
@Component({
selector: 'app-tree',
templateUrl: './tree.component.html',
styleUrls: ['./tree.component.css']
})
export class TreeComponent implements OnInit { …Run Code Online (Sandbox Code Playgroud)