mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Person ordering
This commit is contained in:
1 parent
34850a89fa
commit
c589080ef2
1 file changed
+12
@@ -45,6 +45,18 @@ class Person : Record {
|
||||
override func didInsertWithRowID(rowID: Int64, forColumn column: String?) {
|
||||
id = rowID
|
||||
}
|
||||
|
||||
override func insert(db: Database) throws {
|
||||
|
||||
// Basic Ordering
|
||||
if self.position == 0 {
|
||||
if let maxPosition = Int.fetchOne(db, "SELECT MAX(position) from persons") {
|
||||
self.position = maxPosition + 1
|
||||
}
|
||||
}
|
||||
|
||||
try super.insert(db)
|
||||
}
|
||||
}
|
||||
|
||||
extension Person : Equatable { }
|
||||
|
||||
Reference in new issue
Block a user