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

Return information indicating whether update of relationship was successfull #37

Closed
JonasHiltl opened this issue Nov 15, 2021 · 2 comments

Comments

@JonasHiltl
Copy link

When updating a relationship with the updateRelationship method either through an instance or the model itself it is not possible to know if the update was successfull or if for example the target was icorrect.
I tried updating the relationship of a user with the function below and I could not find a value on the result object that indicated if the update was successfull.
For me the records array in the result was always an empty list even when the update was successfull. The updateStatistics also did not change between an update that changed the relationship and an update that did not change anything. Is it possible to return the number of updates that got executed so that we can decide if the update was successfull?

const result = await User.updateRelationship(
  { accepted: false },
  {
    alias: "Friend",
    where: {
      source: {
        id: req.user?.id.trim()!,
      },
      target: {
        id: req.params.id.trim(),
      },
      relationship: {
        accepted: true,
      },
    },
  }
);
@themetalfleece
Copy link
Owner

updateRelationship returns the query result as is (from the neo4j driver), so there is nothing that Neogma can generate that isn't already there.

Does the following have any useful information?

console.log(result.summary.counters.updates());

@JonasHiltl
Copy link
Author

propertiesSet returns the number of properties that got updated. I will use that to determine if the update was successfull. Thanks a lot

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

2 participants