小编cha*_*eed的帖子

猫鼬模式对象中的时间格式

我有如下所示的架构对象

 schedule: [{
        time: {
            type: Date,
            required: true
        }
    }]
Run Code Online (Sandbox Code Playgroud)

当我尝试在邮递员中发布数据时

"schedule":[
      {
         "time":"18:00:00"
      }]
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

验证失败:schedule.1.time:值“12:00:00”的转换为日期失败

如果我定义typeString,一切正常。

我认为我定义接受时间的类型是错误的。任何人都可以帮助我找到更好的方法来定义对象类型

mongoose node.js mongoose-schema

4
推荐指数
1
解决办法
1万
查看次数

服务未返回数据

我有一个服务,其方法如下:

getTotalCountries() {
    this.http.get("country").subscribe((response) => {
      console.log(response.json());//it is displaying all the data which is return by API
      return response.json();           
    });
}
Run Code Online (Sandbox Code Playgroud)

以类似的方式,我在组件中具有如下功能:

public users: any

countCountry() {
    this.count=this.user.getTotalCountries();
    console.log(this.count) //it is not returning any data;
}
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚为什么它不返回component.ts. 有人可以帮我吗?

typescript angular

3
推荐指数
1
解决办法
639
查看次数

标签 统计

angular ×1

mongoose ×1

mongoose-schema ×1

node.js ×1

typescript ×1