是否有一种通用方法可以从值列表中设置映射器中的字段值?
有没有一种方法可以创建在模型字段中设置值的方法而不显式设置值,例如 -
ModelName.create.fieldName1("value").fieldName2("value2") 和等等
我们可以迭代该模型的所有可用字段并从某些值列表中设置它们的值吗?
类似...
Model.allFields.foreach((fld)=> {
fld.set(valueList(indx));索引+=1
实际上
我想使用一些适用于所有模型的通用方法将值设置到所有模型中。
Is there a way of creating method for setting the value in the Model's fields without setting the values explicitly like -
ModelName.create.fieldName1("value").fieldName2("value2") and so on
Can we iterate through all available fields of that model and set their values form some list-of-values ?
something like ...
Model.allFields.foreach((fld)=> {
fld.set(valueList(indx)); indx+=1
}
Actually I want to set values into all models using some generic method that works for all models.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我的评论:
According to my comment: