-
Notifications
You must be signed in to change notification settings - Fork 26
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
Modify is not working properly #27
Comments
Ok, it looks like I've found a workaround for this problem. MongoDriver doesn't care about syncing Fluent's required Required changes: final class Post: Model {
+ var id: Node? // required to conform Fluent protocol
+ var _id: Node? // required to store correct value in db
var text: String
init(node: Node, in context: Context) throws {
+ id = try node.extract("id")
+ _id = try node.extract("_id")
text = try node.extract("text")
}
func makeNode(context: Context) throws -> Node {
return try Node(node: [
- "id": id, // we don't want to double values in response
+ "_id": id,
"text": text
])
} But I think this issue still needs to be addressed on driver level. |
This should work by just having |
@tannernelson probably yes, but I decided to keep track of |
What kind of safety? Fluent expects that the |
Yeah, your example is cleaner, just thought |
Hi Every one! I'm facing an issue when I fetch my documents by Entity.All(), this happens when I get a Document with another embedded document. In my model, I'm setting a relationship between User Entity that contains an embedded Token document in the userTokenId property, bellow you can see how I wrote my objects. User Model.
Token Model
When I save one user at the first time I had this response. The relation seems works fine when I save the object through Modify Fluent method as you can see below. On the DB the collection looks ok as well. User Document. Token Document. However the issue comes up when I get my document through User.all(), the id of the token Entity comes nil. I'm not sure if this is an issue on my model, I appreciate some advice to know what can I do about that. |
you guys should try again after #48 is merged |
I noticed a critical bug in driver behavior. Modify functionality is not working as expected. I think issue is connected to #25 but I want to describe it in more detail. Steps to reproduce (you can run locally example app - https://github.com/voronianski/vapor-server-example/ to repro):
curl -H "Content-Type: application/json" -X POST -d '{"text":"some"}' POST https://localhost:8080/posts
curl -H "Content-Type: application/json" -X POST -d '{"text":"some change"}' PATCH https://localhost:8080/posts/63214f58d66cdc2b54b99b99
Observe that
"text"
was updated in a wrong document. It looks like driver makes wrong query to update document and matches first one withoutid
field.Implementation of Controller and Model:
update
method in Controller - https://github.com/voronianski/vapor-server-example/blob/master/Sources/App/Controllers/PostController.swift#L25-L36The text was updated successfully, but these errors were encountered: