neogma icon indicating copy to clipboard operation
neogma copied to clipboard

dataValues returns relationship information while getDataValues does not

Open Ansis100 opened this issue 1 year ago • 0 comments

The getDataValues method uses the model schema to gather all data properties of an instance: https://github.com/themetalfleece/neogma/blob/7bb78abd7c239f29317f4bfe00d0159c0690275d/src/ModelOps/ModelOps.ts#L534-L542 This is will only return the instance properties.

However, during the build process of a new instance, the dataValues property gets defined using both schema and relationships: https://github.com/themetalfleece/neogma/blob/7bb78abd7c239f29317f4bfe00d0159c0690275d/src/ModelOps/ModelOps.ts#L581-L594

This means using instance.dataValues will return not only the instance properties, but also a Neogma-specific parameter for the instance's relationship, e.g.:

{
    "name": "test",
    "uuid": "3806f29b-257c-4e12-be6b-6b8c1fe88e2f"
    "relationAlias": {
      "where": [
        {
          "params": {
            "name": "test2"
          }
        }
      ]
    },
  }
}

This might be intended but it was the source of some confusion. In my opinion, dataValues should not contain relationship info.

Ansis100 avatar Feb 19 '24 08:02 Ansis100