我在 Mongoose 模型上有 2 个字段:totalAttempts 和totalRight。我打算根据它们计算准确性。
totalAttempts: {
type: Number,
default: 1
},
totalRight: {
type: Number,
default: 1
}
Run Code Online (Sandbox Code Playgroud)
这就是我所做的[它不起作用]
accuracy:{
type:Number,
required:function() {return (this.totalRight/this.totalAttempts*100).toFixed(2)}
}
Run Code Online (Sandbox Code Playgroud)
另外,如果我不为准确度设置默认值,我会收到错误:
ERROR; While creating new question ..ValidationError: Path `accuracy` is require d.
events.js:163
Run Code Online (Sandbox Code Playgroud)
实现这一目标的正确方法是什么?我已经有了一个可行的解决方案,可以在每次用户请求该模型时获取totalAttempts 和totalRight。但我想保存该计算并将信息存储在我的数据库中。
查看 AWS Glue Schema Registry 的文档,您似乎无法将其用于 Node.js 或 Ruby on Rails:
AWS Glue Schema 注册表支持 AVRO (v1.10.2) 数据格式和 Java 语言支持,其他数据格式和语言即将推出 https://docs.aws.amazon.com/glue/latest/dg/schema-registry.html
注意先决条件:在完成以下步骤之前,您需要运行 Managed Streaming for Apache Kafka (MSK) 或 Apache Kafka 集群。您的生产者和消费者需要在 Java 8 或更高版本上运行。 https://docs.aws.amazon.com/glue/latest/dg/schema-registry-gs.html
有人有幸将 AWS Glue Schema Registry 与 Node.js 或 Ruby on Rails 一起使用吗?
我只是想知道是否.length()只是一个别名,.length因为它们返回相同的结果:
[38] pry(main)> temp = [1,2,3]
=> [1, 2, 3]
[40] pry(main)> temp.length
=> 3
[41] pry(main)> temp.length()
=> 3
Run Code Online (Sandbox Code Playgroud) 我已经知道当我们有Key-Value对时我们使用HashMap,而当我们不需要重复数据时我们使用HashSet.但是我总是对Hashtable发挥作用感到困惑.它是一个完全不同的数据结构吗?或者HashMap和HashSet都使用哈希函数在Hashtable中存储数据?彻底的解释将非常有用.
我知道Snackbar只是为了显示一条短信.但我的其中一个要求我打印多行.那可能吗?