Open
Description
Version : v1.3.1
Description:
When I use the PropertyQuery
method to query, the sorting is incorrect
// objectbox: entity
final class Item {
var id: Id = 0
var data: Int64 = 0
var created: Int64 = 0
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let store = try! createStore()
let box: Box<Item> = store.box()
putData(box: box)
let build = try! box.query().ordered(by: Item.created).build()
let values = try! build.property(Item.data).find()
let times = try! build.property(Item.created).find()
print(values)
print(times)
}
private func putData(box: Box<Item>) {
let value: [Int64] = [64087, 56654, 427, 95156, 75358]
let times: [Int64] = [1596884723268, 1596884598790, 1596883589545, 1596880357258, 1596878457071]
for i in 0..<value.count {
let item = Item()
item.created = times[i]
item.data = value[i]
try! box.put(item)
}
}
}
private func createStore() throws -> Store {
let directory = try FileManager.default.url(
for: .applicationSupportDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: true
).appendingPathComponent("Test")
try? FileManager.default.createDirectory(at: directory, withIntermediateDirectories: false, attributes: nil)
return try Store(directoryPath: directory.path)
}
Output:
[64087, 56654, 427, 95156, 75358]
[1596884723268, 1596884598790, 1596883589545, 1596880357258, 1596878457071]