-
Notifications
You must be signed in to change notification settings - Fork 22
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
save dynamically deep document #8
Comments
I put in a setting that uses the toObject was in the tree. I see a lot of functions would be needed. The 2.0 version is a closer look through and think about it. |
Just a thought. Save the document a problem, because: The mongoose is trying to save the children attribute. |
Hmm interesting, but you completely misunderstood my ticket (I am terrible at explaining what I think especially in English). But with your 2 answers I am able to explain it a bit more and directly see that I am also doing wrong stuff with Mongoose. Basically I want to save a document which is dynamically (so you don't know which properties it has just that it is a valid object). To save something like this through mongoose I have the schema strict option set ot false. This so that I can also save properties which aren't defined in the Schema. This however isn't possible with the materialized plugin because we only have a document.save() method. So basically if we did have a
method it would be possible to dynamically modify fields inside a unknown document. And ofcourse it would be super awesome if we could integrate it with some operators but I guess that is going to far and will be to dangerous since you are more likely to add operators that will eventually break the tree. Anyhow a findByIdAndUpdate sort of function would be ideal! |
Sorry my English is not so good. Sorry, I think I missed one of two details. I think during the valid that the children attribute with strict option is not defined. If you want update the document inside of tree, you can retrieve it again from db, and update fields with Unfortunately, the I called this to the attention. In "important" section the method list: https://github.com/janez89/mongoose-materialized#instructions I see one more chance. |
I wan't to dynamically update a document (so I don't know which key/values get passed to the save function). And the key/values can be nested prety deep, Once again you don't know how deep.
Currently I do this by first getting the document from the database and extend it with the data passed to the update. However this way the document also get converted to a plain object (toObject()).
Big downside of this is that we can't use the .save() method any more because it has become a plain object. Big no no of this story is that the parentId is (maybe) updated in the progress but the path doesn't get updated.
Is there some way to dynamically update a deep nested document while also updating the materialized path?
Maybe it's a idea to also make a method which will only update a specific document its path (or starting from that document it's path and recursively do all it's children), much like the .Building does now but only from the updated document it's id.
Note: to explain it a bit more, this is what is basically wanna do but in less functions (somehow this doesn't work though. The parentId does get updated but the path doesn't)
The text was updated successfully, but these errors were encountered: