对CosmosDB存储过程及其处理new Date()和日期比较的指导有限 .
以下代码是一个CosmosDB存储过程,用于在给定时间后"冻结"文档的写入.该物业currentDoc.FreezeDate采用ISO-8601格式,例如'2017-11-15T13:34:04Z'.
注意:这是我想要了解的情况的一个例子.它不是生产代码.
function tryUpdate(newDoc) {
__.queryDocuments(
__.getSelfLink(),
{ /* query to fetch the document */ },
(error, results) => {
var currentDoc = results[0]; // doc from the database
// fail if the document is still locked
if (new Date(currentDoc.FreezeDate) < new Date()) {
getContext().getResponse().setBody({ success: false });
return;
}
// else update the document
/* snip */
}
);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:在CosmosDB存储过程中,new Date()受时区的影响,特别是考虑到数据库可能与调用代码位于不同的区域?这里的日期比较代码在所有情况下都有效吗?
import { Component, Prop } from '@stencil/core';
@Component({
tag: 'my-component',
styleUrl: 'my-component.css',
shadow: true
})
export class MyComponent {
@Prop() first: string;
@Prop() last: string;
getElementHere() {
// how can I get the div here?
}
render() {
return (
<div>
Hello, World! I'm {this.first} {this.last}
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
我想像在原生 JS 中一样获取 DOM 元素。你如何在 Stencil 中做到这一点?getElementById不起作用。
我有一个使用的角度1.5.5项目jspm获取和捆绑的所有前端的依赖- ,angular,,angular-material 等.angular-adalngcomponentrouter
我们正在使用npm:端点解析所有这些依赖项.当我们安装时会出现问题angular-material,因为它angular从github:angular/bower-angular(而不是npm:angular)拉入第二依赖.
这可以通过运行来复制:
jspm install npm:angular
jspm install npm:angular-material
Run Code Online (Sandbox Code Playgroud)
其中第二个命令输出:
Looking up npm:angular-material
Updating registry cache...
Downloading npm:angular-material@1.1.0-rc4-master-06e7e99
Looking up github:angular/bower-angular
Looking up github:angular/bower-angular-messages
Looking up github:systemjs/plugin-css
Looking up github:angular/bower-angular-animate
Looking up github:angular/bower-angular-aria
ok Installed github:angular/bower-angular-messages@^1.5.3 (1.5.5)
ok Installed github:angular/bower-angular@^1.5.3 (1.5.5)
ok Installed github:angular/bower-angular-aria@^1.5.3 (1.5.5)
ok Installed github:angular/bower-angular-animate@^1.5.3 (1.5.5)
Run Code Online (Sandbox Code Playgroud)
导致角度被我们的UI加载两次 - 一次来自wwwroot/lib/github/angular一次wwwroot/lib/npm/angular@1.5.5
我的问题是:
有没有办法强制angular只从一个源解决相同的依赖?如何确保仅加载角度1.5.5的单个依赖项?