Skip to content
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

Support for reference document inside embedded document #107

Open
ofirbw opened this issue May 14, 2017 · 0 comments
Open

Support for reference document inside embedded document #107

ofirbw opened this issue May 14, 2017 · 0 comments

Comments

@ofirbw
Copy link

ofirbw commented May 14, 2017

Hi there,

Why there is no support for reference document inside an embedded document? it's just take the whole data instead of what i expected to save which is the embedded data along with the id for the reference document.
` // Replace EmbeddedDocument references with just their data
_.keys(that._schema).forEach(function(key) {
if (isEmbeddedDocument(that[key]) || // isEmbeddedDocument OR
(isArray(that[key]) && // isArray AND contains value AND value isEmbeddedDocument
that[key].length > 0 &&
isEmbeddedDocument(that[key][0]))) {

                // Handle array of references (ex: { type: [MyObject] })
                if (isArray(that[key])) {
                    toUpdate[key] = [];
                    that[key].forEach(function(v) {
                        toUpdate[key].push(v._toData());
                    });
                } else {
                    toUpdate[key] = that[key]._toData();
                }

            }
        });`

The line toUpdate[key].push(v._toData()); just take the whole data, can I replace this with the _id of the document and handle the read part or this is a bad approach?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant