我有一个Express(Node.JS)+ MongoDB应用程序,服务器响应加载时间平均为4 - 7秒(慢).
据我所知,根据google pagespeed工具,平均服务器响应时间不到200毫秒.
这个应用程序异步获取mongoDB中的数据,但到数据库的往返时间非常慢,每次调用平均大约500ms - 1s.这些调用是简单的findAll调用,用于检索少于<100条记录的数据.
我检查了我的数据库指标,看起来很好.也没有缓慢的查询.这些是简单的findAll查询.mongo atlas的绩效顾问报告没什么异常.
生产应用程序和数据库都托管在同一区域中.
我已经尝试通过运行.lean()来优化查询的应用程序层(mongoose)
我还应该在哪里改进数据库延迟?一个简单的查询怎么能花这么长时间?否则,为什么我的服务器响应时间在预期的大约200毫秒时需要4秒?
在Graphene Python 中,schema.py当无法访问HttpResponse要设置 cookie的对象时,应该如何设置 cookie?
我当前的实现是通过捕获data.operationName. 这涉及我需要设置 cookie 的操作名称/突变的硬编码。
在views.py中:
class PrivateGraphQLView(GraphQLView):
data = self.parse_body(request)
operation_name = data.get('operationName')
# hard-coding === not pretty.
if operation_name in ['loginUser', 'createUser']:
...
response.set_cookie(...)
return response
Run Code Online (Sandbox Code Playgroud)
有没有更简洁的方法来为特定的 Graphene Python 突变设置 cookie?
tldr; fireEvent.change 有效,但在表单提交时,未在提交处理程序中找到新值。
假设我们有一个简单的形式:
// MyForm.tsx
class MyForm extends React.Component {
state = { data: '123' }
handleChange = (e: any) => {
// This never gets fired in the test, why?
console.log('HandleChange Fired', e.target.value)
this.setState({ data: e.target.value })
}
handleSubmit = () => {
console.log('************* HandleSubmit Fired **************', this.state)
}
render() {
return (
<form name="address" onSubmit={this.handleSubmit}>
<input name="title" value={this.state.data} onChange={this.handleChange} />
<button type="submit">Submit</button>
</form>
)
}
}
Run Code Online (Sandbox Code Playgroud)
和断言表单提交值的测试是准确的:
// MyForm.spec.tsx
import React from 'react'
import { expect } …Run Code Online (Sandbox Code Playgroud) 我应该在下面示例中的 JSDoc @param 块中添加什么,以使我的 IntelliJ Webstorm IDE 停止抛出错误:Argument Type ComponentClass<undefined>不可分配给参数类型???...`?
/**
* Renders the passed component into a div
* @param { ??? } component // Question: <<<
*/
const myRenderFunc = (component) => (
<div>{component}</div>
)
Run Code Online (Sandbox Code Playgroud) 我有6个图像加载到不同的6个不同的模态窗口,它们每个都有一个下一个按钮,还有一个关闭按钮.下一个按钮使用以下jquery代码:
$('#nextModal12').click(function() {
$('#featuresModal1').modal('hide');
$('#featuresModal1').on('hidden.bs.modal', function () {
$('#featuresModal2').modal('show');
document.getElementById('#featuresModal1').style.display="none";
});
});
$('#nextModal23').click(function() {
$('#featuresModal2').modal('hide');
$('#featuresModal2').on('hidden.bs.modal', function () {
$('#featuresModal3').modal('show');
document.getElementById('#featuresModal2').style.display="none";
});
});
Run Code Online (Sandbox Code Playgroud)
但是,问题是:即使我通过单击CLOSE按钮而不是下一个按钮来关闭/隐藏第一个模态('#nextModal12'),也会出现第二个模态.
我相信这是因为即使我没有点击下一个按钮,也会拾取并再次调用hidden.bs.modal函数.如何防止脚本不加选择地拾取hidden.bs.modal函数?