Skip to content

Instantly share code, notes, and snippets.

@candostdagdeviren
Last active May 21, 2017 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save candostdagdeviren/c5fd784e5c30e65b62044e41ce4c7f95 to your computer and use it in GitHub Desktop.
Save candostdagdeviren/c5fd784e5c30e65b62044e41ce4c7f95 to your computer and use it in GitHub Desktop.
Vapor 1 -> 2 Migration
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