-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Suggestion. How about changing the variable name idKeypath?
Nice to meet you, I recently started studying Kitura. Thank you for your daily maintenance!
This is my personal opinion, but I would be happy if you could refer to it.
This is a quote from this site,
Using optional ID properties
Declaring your ID property as optional allows the ORM to assign the ID automatically when the model is saved. If the value of ID is nil, the database will assign an auto-incremented value. At present this is only support for an Int? type.You may instead provide an explicit value, which will be used instead of automatic assignment.
Optional IDs must be identified by defining the idKeypath: IDKeyPath property, as in the example below:
struct Person: Model {
var id: Int?
var firstname: String
var surname: String
var age: Int
static var idKeypath: IDKeyPath = \Person.id
}I think the idKeypath property should be written in LowerCamelCase. What do you think?
In fact, I didn't work because I declared the idKeyPath property.
Environment Details
- MacOS ... Catalina 10.15 beta
- Xcode ... 10.3
- Swift ... 5.0
Steps to Reproduce
- ...
Define a structure that inherits Model, declareidKeyPathas a property, and confirm that it does not work. - ...
You will notice that it is anidKeypathproperty instead of anidKeyPathproperty, and fix the code. I think it works well.
Expected vs. Actual Behaviour
- Expected to happen (I would like to write like this) ...
struct Diary: Equatable, Model {
var id: Int?
var title: String?
static var idKeyPath: IDKeyPath = \Diary.id
}- Actually happened (current way) ...
struct Diary: Equatable, Model {
var id: Int?
var title: String?
static var idKeypath: IDKeyPath = \Diary.id
}