我想制作一个只能由一位用户申请一天的报告,因此用户无法在同一天发布双重记录。 这是代码
//我使用ionic和firebase
这是html的代码
context.Result = new BadRequestResult();
context.HttpContext.Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "Não foi encontrado.";
这是ts的代码
.cftv_representante_form {
background-color: rgb(82, 82, 82);
color: #fff;
}
.cftv_representante_form {
display: grid;
grid-auto-columns: auto;
grid-auto-rows: auto auto auto auto auto auto auto auto auto auto auto;
grid-template-areas: "h1" "p" "nome1" "nome2" "email1" "email2" "cpf1" "cpf2" "telefone1" "telefone2" "botao"
}
.cftv_representante_form p {
padding: 5px 0 30px 0;
}
.cftv_representante_form input {
font-size: 1.5em;
border-radius: 15px;
width: 100% !important;
color: #000;
border: 1px solid rgba(255,255,255,0.3);
margin-top:10px;
margin-bottom: 10px;
padding: 10px;
}
@media screen and (min-width: 540px) {
.cftv_representante_form {
display:grid;
grid-auto-columns: auto 15px auto !important;
grid-auto-rows: auto auto auto auto auto auto auto !important;
grid-template-areas: "h1 h1 h1" "p p p" "nome1 nome1 nome1" "nome2 nome2 nome2" "email1 email1 email1" "email2 email2 email2" "cpf1 . telefone1" "cpf2 . telefone2" "botao botao botao" !important;
}
}
我只是使用标准代码将数据推送到firebase 使用此代码,我可以在同一天上传报告。
答案 0 :(得分:0)
您可以查看Firebase以查找比一天(以毫秒为单位)更新的现有报告。如果有关系,请允许插入新的。
从Firebase过滤报告的方法:
const yesterday = Date.now() - (24 * 60 * 60 * 1000);
db
.list<Report>('/laporan/' + this.id)
.valueChanges()
.map(reports => reports.filter(report => report.mydate > yesterday))
.subscribe(reports => {
if (reports.length === 0) {
// insert report in Firebase
}
console.log(reports);
});
注意:mydate
=自1970年1月1日00:00:00 UTC以来经过的毫秒数。