我有一个问题,当我将两个对象类型作为远程方法参数传递时,第一个参数被第二个参数覆盖.以下是代码和结果.我怎么能不让第二个参数不覆盖第一个参数呢?
module.exports = (Model) => {
Model.calculate = (primary, secondary) => {
console.log(JSON.stringify(primary, null, 2));
console.log(JSON.stringify(secondary, null, 2));
return new Promise((resolve, reject) => {
resolve({ Model: calculator.calculate() });
});
};
Model.remoteMethod('calculate', {
accepts: [
{ arg: 'primary', type: 'object', http: { source: 'body' } },
{ arg: 'secondary', type: 'object', http: { source: 'body' } }
],
returns: {arg: 'Result', type: 'string'}
});
};
Run Code Online (Sandbox Code Playgroud)
当我在控制台记录JSON对象primary和secondary后传入主参数{"name":"Tom"}和辅助参数{"name:"Joe"}时,我得到了结果.
primary
{
"name": "Joe" <--- WHY?!
}
secondary
{
"name: "Joe"
}
Run Code Online (Sandbox Code Playgroud)
如你所见,汤姆被乔覆盖了.
我的 copy_to 可以正常工作以进行精确匹配,但我无法使用部分匹配正确设置它。以下是我的映射/设置以及预期和实际结果的查询。
设置:
{
"test": {
"settings": {
"index": {
"analysis": {
"filter": {
"ngram_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "15"
}
},
"analyzer": {
"ngram_analyzer": {
"filter": [
"lowercase",
"ngram_filter"
],
"type": "custom",
"tokenizer": "standard"
}
}
},
"number_of_shards": "1",
"number_of_replicas": "1",
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
映射:
POST /test/_mapping/name
{
"name": {
"properties": {
"vital": {
"properties": {
"first": {
"type": "string",
"copy_to": "full_name",
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
},
"last": {
"type": "string",
"copy_to": "full_name", …Run Code Online (Sandbox Code Playgroud) 我遇到一个问题,nodemailer-express-handlebars 输出错误:
\n[Error: ENOENT: no such file or directory, open ''] {\n errno: -2,\n code: 'ENOENT',\n syscall: 'open',\n path: '/Users/person/Code/app/api/controllers/templates/undefined.hbs'\nRun Code Online (Sandbox Code Playgroud)\n我的设置如下:
\n const handlebarOptions = {\n viewEngine: {\n extName: ".hbs",\n partialsDir: path.resolve(__dirname, "templates"),\n defaultLayout: false\n },\n viewPath: path.resolve(__dirname, "templates"),\n extName: ".hbs"\n };\n\n transporter.use('compile', hbs(handlebarOptions));\nRun Code Online (Sandbox Code Playgroud)\n并发送电子邮件:
\n let mailOptions = await transporter.sendMail({\n from: '"Test - No Reply" <test@test.com>'\n to: 'someEmail@gmail.com, \n subject: "Hello \xe2\x9c\x94",\n template: 'welcome',\n });\nRun Code Online (Sandbox Code Playgroud)\n奇怪的是,我仍然收到电子邮件,尽管它说找不到该文件。如何解决此错误并使 nodemailer-express-handlebars 不会将文件视为“undefined.hbs”?
\n更新:
\n我在节点邮件程序中将“welcome”更改为“welcome.hbs”,现在错误提示找不到“welcome.hbs.hbs”。这是有道理的,您可能认为解决方案是删除“.hbs”并使其“欢迎”,但随后我们又回到了“undefined.hbs”的原始错误。
\n另外,如果我将模板更改为“welcome2”,它会说找不到“welcome2.hbs”。它很奇怪......就好像只有当模板文件与它应该是的文件名匹配时它才变得未定义。
\n我正在将 Klarna 集成到与 Adyen 相关的沙盒环境中。我已经精确地遵循了文档,但遇到了一个问题,即小部件中没有显示“继续”按钮,从而阻止了结帐过程。
-预期的-
-实际(缺少按钮)-
重新创建的代码:
发布到: https://checkout-test.adyen.com/v67/payments
{
"merchantAccount": "MERCHANTLLC",
"reference": "123",
"paymentMethod": {
"type": "klarna_account"
},
"amount": {
"currency": "USD",
"value": 18210
},
"shopperLocale": "en_US",
"countryCode": "US",
"telephoneNumber": "1111111111",
"shopperEmail": "test@gmail.com",
"shopperName": {
"firstName": "John",
"lastName": "Doe"
},
"returnUrl": "http://someurl.com",
"lineItems": [
{
"quantity": 1,
"amountExcludingTax": "16900",
"taxPercentage": "775",
"description": "asdfasdf",
"id": "123",
"taxAmount": 1310,
"amountIncludingTax": "18210",
"productUrl": "http://producturl.com"
}
]
}
Run Code Online (Sandbox Code Playgroud)
它返回client_token:“ABC123”。然后使用该令牌通过klarna 文档加载小部件:
window['Klarna']['Payments'].init({
client_token: 'ABC123'
})
window['Klarna']['Payments'].load({
container: …Run Code Online (Sandbox Code Playgroud) 我有一个直截了当的问题,我已将ngram的部分匹配纳入其中.实施效果很好,但得分结果并不像我希望的那样有效.我希望我的得分结果看起来像这样:
相反,我得到以下结果,如果该字段匹配,则得分相同:
设置:
settings: {
analysis: {
filter: {
ngram_filter: {
type: 'edge_ngram',
min_gram: 2,
max_gram: 15
}
},
analyzer: {
ngram_analyzer: {
type: 'custom',
tokenizer: 'standard',
filter: [
'lowercase',
'ngram_filter'
]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
映射:
mappings: [{
name: 'voter',
_all: {
'type': 'string',
'analyzer': 'ngram_analyzer',
'search_analyzer': 'standard'
},
properties: {
last: {
type: 'string',
required : true,
include_in_all: true,
analyzer: 'ngram_analyzer',
search_analyzer: 'standard'
},
first: {
type: 'string',
required : …Run Code Online (Sandbox Code Playgroud) 我目前有工作代码执行请求并检查它是否收到成功的状态代码200.我希望在此增长并循环它将继续发送请求,直到状态代码为200.我尝试使用while循环但没有收到正确的结果.谢谢您的帮助!
request('http://0.0.0.0:9200', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log('success');
do(something);
}
else {
console.log('fail');
}
});
Run Code Online (Sandbox Code Playgroud) 当我设置到期日期对象时,我遇到了这种情况.更改'expire'后,'object.created'会在不应该更改时更改.为什么'object.created'会改变?谢谢!
let expire = object.created; // object.created: Wed Mar 02 2016
expire.setDate(12);
console.log(expire); // Wed Mar 12 2016
console.log(object.created); //Wed Mar 12 2016 <-- WHY?!
Run Code Online (Sandbox Code Playgroud) Promise.all() 在 Javascript 中是顺序运行还是并行运行?
例如:
const promises = [promise1(), promise2(), promise3()]
Promise.all(promises)
.then(data => {
// whatever
});
Run Code Online (Sandbox Code Playgroud)
是promise1()在转到promise2() 之前执行并解析,还是promise1()、promise2()、 和promise 3()全部同时并行运行?我会假设浏览器中的 Node、Javascript 是单线程的,因此它们不会并行运行?
在使用IP 192.168.3.10编写skydns-svc.yml文件后,我收到以下错误:
Error: The Service "kube-dns" is invalid:spec.clusterIP: Invalid value: "192.168.3.10": provided IP is not in the valid range
Run Code Online (Sandbox Code Playgroud)
skydns-svc.yml
apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "KubeDNS"
spec:
selector:
k8s-app: kube-dns
clusterIP: 192.168.3.10
ports:
- name: dns
port: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
Run Code Online (Sandbox Code Playgroud)
这怎么不在有效范围内,我怎么能解决错误?使用V1.2
javascript ×4
mapping ×2
node.js ×2
object ×2
partial ×2
settings ×2
adyen ×1
angular ×1
arguments ×1
asynchronous ×1
creation ×1
date ×1
express ×1
http ×1
klarna ×1
kubernetes ×1
loopbackjs ×1
loops ×1
nodemailer ×1
overwrite ×1
promise ×1
request ×1
scoring ×1
search ×1
service ×1
strongloop ×1
variables ×1
yaml ×1