Last active
May 21, 2017 05:52
-
-
Save candostdagdeviren/c5fd784e5c30e65b62044e41ce4c7f95 to your computer and use it in GitHub Desktop.
Vapor 1 -> 2 Migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class User: Model { | |
init(node: Node, in context: Context) throws { | |
id = try node.extract("_id") // Trick for MongoDB database | |
name = try node.extract("name") | |
score = try node.extract("score") | |
} | |
func makeNode(context: Context) throws -> Node { | |
return try Node(node: [ | |
"_id": id, // Trick for MongoDB database | |
"name": name, | |
"score": score | |
]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment