-
-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Difference fields in database and data model #438
Comments
Hi @Mahdimm,
You did not say much, so I'll suppose that you use the PersistableRecord protocol, the one which provides the GRDB persistence methods such as You control the stored columns with the func encode(to container: inout PersistenceContainer) {
container["id"] = id
container["name"] = name
container["lastName"] = lastName
} If you happen to use the standard Encodable protocol on top of PersistableRecord, then refer to the "Choose Properties to Encode and Decode Using Coding Keys" paragraph of the Encoding and Decoding Custom Types documentation. |
thanks for replay @groue We solved problem in this way and maybe this code help someone who is searching for same problem:
|
Glad you found your solution, @Mahdimm! Happy GRDB! |
Hello @groue, in init(from decoder: Decoder) throws function, lastName is optional, to set value for this; @Mahdimm use above line, is that okey? or are there any better ways? because if we use like this: Thanks for your response. |
Hello @MrShafiee. Your question is not about GRDB, but about the standard Decodable protocol. Please refer to Apple documentation, or ask your question on Stack Overflow. Thank you. |
Hi @tonyarnold
I have a table with 3 columns but its model has 4 properties, What should I do in this case? because when I set insert query I got this error:
My table columns are: id, name, lastName
My model properties: id, name, lastName, age
is there any protocol that I can fix this problem?
The text was updated successfully, but these errors were encountered: