当我从 MongoDB 获取记录时,获取的文档不具有数据库中存在的属性,而是空对象。我是否应该添加一些配置来获取空对象的属性?
我正在尝试使用 mongoose 连接到我的数据库,并且在我的控制台中显示“不支持选项 usefindandmodify ”。我正在使用猫鼬 6.0.0
这是我的代码
mongoose.connect(constants.CONNECTION_URL,
{ useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
})
.then(() => app.listen(constants.PORT, () => console.log(`Server Running on Port ${constants.PORT}`)))
.catch((error) => console.log(error.message));
mongoose.Promise = global.Promise;
Run Code Online (Sandbox Code Playgroud)
有人可以建议我如何摆脱它吗?如果绿色和红色都不重要,则用白色书写。
实施 Passport.js 进行身份验证时遇到错误。会话集合有数据解析,但是,我收到此错误:
TypeError: Cannot read properties of undefined (reading 'initialize')
at Authenticator.initialize (\server\node_modules\passport\lib\authenticator.js:130:26)
at Layer.handle [as handle_request] (\server\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (\server\node_modules\express\lib\router\index.js:317:13)
at \server\node_modules\express\lib\router\index.js:284:7
at Function.process_params (\server\node_modules\express\lib\router\index.js:335:12)
at next (\server\node_modules\express\lib\router\index.js:275:10)
at session (\server\node_modules\express-session\index.js:479:7)
at Layer.handle [as handle_request] (\server\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (\server\node_modules\express\lib\router\index.js:317:13)
at \server\node_modules\express\lib\router\index.js:284:7
Run Code Online (Sandbox Code Playgroud)
我的 index.js 文件包含以下内容:
TypeError: Cannot read properties of undefined (reading 'initialize')
at Authenticator.initialize (\server\node_modules\passport\lib\authenticator.js:130:26)
at Layer.handle [as handle_request] (\server\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (\server\node_modules\express\lib\router\index.js:317:13)
at \server\node_modules\express\lib\router\index.js:284:7
at Function.process_params (\server\node_modules\express\lib\router\index.js:335:12)
at next (\server\node_modules\express\lib\router\index.js:275:10)
at session (\server\node_modules\express-session\index.js:479:7)
at Layer.handle [as handle_request] …Run Code Online (Sandbox Code Playgroud) 我有一个 MatDialog,它在构造时由其父级提供了一个 HTML 字符串。HTML 字符串是命名 div 内容的来源,并且包含<table>嵌入 html 中的标签,但由于某种原因,对话框的 scss 文件中定义的表格样式不适用于我指定为 的字符串[innerHTML],尽管它对于<table>标签来说效果很好直接硬编码到html文件中。
有什么方法可以让对话框使用对话框组件的样式模板中包含的样式来渲染innerHTML?
export class DialogAgreementViewer implements AfterViewInit {
constructor(public dialogRef:
MatDialogRef<DialogAgreementViewer>, @Inject
(MAT_DIALOG_DATA) public data: string, protected _sanitizer : DomSanitizer){
this.agreementText = this._sanitizer.bypassSecurityTrustHtml(data);
}
public agreementText : SafeHtml;
@ViewChild('agreementText') agreementTextCtl : ElementRef;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<p>Agreement Template</p>
<table>. <-- Defined table styles are applied to this table.
<tbody>
<tr><td>Title</td><td>Name of Work</td></tr>
</tbody>
</table>
<div [innerHTML]='agreementText'></div> <-- Table styles not applied here.
Run Code Online (Sandbox Code Playgroud)
社会保障体系:
table, td …Run Code Online (Sandbox Code Playgroud) eslint -config-prettier和eslint-plugin-prettier都是用于将ESLint与Prettier集成的流行软件包。
然而,在阅读了他们的文档后,我明白两者都可以完成这项工作。但是,如果我们使用eslint-plugin-prettier,就会出现一些使用eslint-config-prettier不会发生的问题。此外,当使用eslint-plugin-prettier推荐配置时,它将在幕后使用eslint-config-prettier 。
在我看来,eslint-config-prettier比eslint-plugin-prettier有明显的优势 ,但eslint-plugin-prettier仍然很受欢迎,并且它在npm上每周的下载量确实很多。我错过了什么?使用eslint-plugin-prettier有什么好处?
我正在使用 Angular 14。我有一个独立组件,我想在其中包含另一个模块的子组件。独立组件看起来像
<div>
<child-component></child-component>
</div>
Run Code Online (Sandbox Code Playgroud)
它的服务文件是
@Component({
selector: 'my-parent-component',
templateUrl: './parent.component.html',
standalone: true,
imports: [
MyModule
]
})
export class ParentComponent {
...
}
Run Code Online (Sandbox Code Playgroud)
子组件位于另一个模块中——MyModule。my.module.ts 文件看起来像
/* imports */
@NgModule({
declarations: [
ChildComponent
],
imports: [
...
]
})
export class MyModule {
constructor(entityDefinitionService: EntityDefinitionService) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
但我父母的 HTML 给了我错误
<child-component></child-component>
Run Code Online (Sandbox Code Playgroud)
线 ...
'app-child-component' is not a known element:
1. If 'app-child-component' is an Angular component, then verify that it is included in the '@Component.imports' of this …Run Code Online (Sandbox Code Playgroud) javascript ×6
express ×3
mongodb ×3
node.js ×3
angular ×2
mongoose ×2
angular14 ×1
components ×1
css ×1
eslint ×1
mat-dialog ×1
module ×1
passport.js ×1
prettier ×1