我首先使用叶子中的Tag,蒸汽来排序日期。从MySQL数据库,它显示日期和时间,但最后我使用" get"在routes.swift中,在网页上以HTML格式显示日期和时间。我的每个实体日期和时间都是从MySQL成功获取的,但是新的用户实体在使用叶子中的#loop后结束。有没有办法在最新的时间和日期首先#loop。下面是代码。
自定义代码
<div class="svg-wrapper">
<svg class="play-vert-line" height="17">
<defs>
<linearGradient id="vert-gradient" gradientUnits="userSpaceOnUse" y1="0%" y2="100%" x1="0" x2="0">
<stop stop-color="#3A9AFC"></stop>
<stop stop-color="#3c3c3c"></stop>
</linearGradient>
</defs>
<line id="vert-line-1" x1="50%" y1="0" x2="50%" y2="17" stroke="url(#vert-gradient)" stroke-width="2"></line>
</svg>
<svg class="line-join" height="15" width="15" viewBox="-1.3 0 15 15">
<defs>
<linearGradient id="vert-join-gradient" gradientUnits="userSpaceOnUse" y2="100%" x1="0" x2="0">
<stop stop-color="#3A9AFC"></stop>
<stop stop-color="#3c3c3c"></stop>
</linearGradient>
</defs>
<path id="vert-line-2" d="M 11, 10 C 5, 10, 1, 6, 1, 0" stroke="url(#vert-join-gradient)" stroke-width="2"></path>
</svg>
</div>
在Routes.swift中
select top 100000 a,id from users ORDER BY NEWID()
machine_overview.leaf
import Leaf
import Fluent
final public class LeafDataPoint: BasicTag {
public var name = "dataPoint"
public func run(arguments: ArgumentList) throws -> Node? {
guard
arguments.count == 3,
let report = arguments[0],
let dataPointName = arguments[1]?.string,
let dateField = arguments[2]?.string
else {
return nil
}
let point = try DataPointFluent.makeQuery()
.filter(DataPointFluent.Keys.reportID,
report.get(ReportFluent.Keys.id) as String)
.filter(DataPointFluent.Keys.name, dataPointName.string)
.first()
switch dateField {
case DataPointFluent.Keys.data:
return point?.data?.makeNode(in: nil)
case DataPointFluent.Keys.displayName:
return point?.displayName.makeNode(in: nil)
default:
return nil
}
}
}
我尝试过loop.isFirst但没有成功。