我知道其中有.filter ()过滤数组以按照我想要的方式返回它,并使用很多来搜索,当我们在该数组中传递我们想要搜索的内容时。
但是,我无法过滤这样的日期数组:
["08:00" "09:00" "10:10" "10:30" "10:50" "11:30" "11:50" "12:00"];
Run Code Online (Sandbox Code Playgroud)
我需要过去的日期,我已经开始日期和结束日期对其进行过滤,例如步骤它" 09:00 "和" 11:30 "它应该返回给我:
["10:10" "10:30" "10:50"]
Run Code Online (Sandbox Code Playgroud)
尝试这样做我在我的typescript:
1. this.schedules = this.navigation.lineSelected.schedules;
2. this.schedules.filter (item => {
3. item> this.hourNow && item <this.hourFinish
4.});
Run Code Online (Sandbox Code Playgroud)
在第 1 行我得到了所有的时间,所以在第 2.4 行我过滤了这个数组,但它返回了所有的东西给我。
我怎样才能做到这一点?
翻译我需要的:
我将有两个小时字符串,例如“12:00”和“15:00”,我需要在数组中进行比较,因为我需要如上例所示的间隔之间的小时数。
当我说 time 我在谈论一个字符串时,所以我需要比较字符串是否大于“12:00”以下的其他类型字符串不会出现在我的最终数组中,并且字符串大于“15” :00" 也不会。
这是我可以解释我需要的最好方法,我看不到任何其他解释选项。简单地过滤一个数组
好吧,我在 mongo 的聚合方面遇到了问题,我需要验证是否在所有答案中都没有标记为 deleteAt 的字段。我的聚合看起来像这样:
[
{ '$match': { _id: "5f0cc0e676de351ce21a752b" } },
{
'$lookup': {
from: 'Exams',
localField: 'exams.idExams',
foreignField: '_id',
as: 'exams'
}
},
{
'$lookup': {
from: 'Sports',
localField: 'idSports',
foreignField: '_id',
as: 'sportPracticed'
}
},
{
'$unwind': { path: '$sportPracticed', preserveNullAndEmptyArrays: true }
},
{
'$lookup': {
from: 'Galery',
localField: '_id',
foreignField: 'idPlayer',
as: 'galery'
}
},
{
'$lookup': {
from: 'EvaluationPlayer',
localField: '_id',
foreignField: 'idPlayer',
as: 'evaluationPlayer'
}
},
{
'$lookup': {
from: 'Evaluation',
localField: …Run Code Online (Sandbox Code Playgroud)