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

Deep creating relations with pass option doesn't work #81

Open
Tyler-Zhang opened this issue May 9, 2019 · 2 comments
Open

Deep creating relations with pass option doesn't work #81

Tyler-Zhang opened this issue May 9, 2019 · 2 comments

Comments

@Tyler-Zhang
Copy link

I can't seem to get this example

const postProps = {
  title: 'Relations',
  comments: [
    {
      content: 'Awesome!'
    },
    {
      content: 'So cool!'
    }
  ]
};

store.create('post', postProps, { pass: ['comments'] })
  .then((post) => {
  	// done
  
		post.id === post.comments[0].post_id; // true!
  });

at https://www.js-data.io/docs/relations#section-deep-creating-relations to work.

Although the objects serialize properly, the base adapter's withoutSerialization call on create, createMany, update, etc... filters out the relations because it expects the whitelisted relations to be specified in opts.with instead of opts.pass.

https://next.plnkr.co/edit/IXtJWp3gDy3fgqfY?preview

@Tyler-Zhang
Copy link
Author

Just copying opts.pass to opts.with works for me:

https://github.com/Tyler-Zhang/js-data-http/tree/fix-deep-creating-relations-with-pass-opts

@Septaris
Copy link

Septaris commented Jun 13, 2019

Copying opts.pass content to opts.with allows to bypass the filtering but it triggers a cascading create.

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

No branches or pull requests

3 participants