themetalfleece / neogma

Object-Graph-Mapping neo4j framework, Fully-typed with TypeScript, for easy and flexible node and relationship operations
https://themetalfleece.github.io/neogma/
MIT License
117 stars 12 forks source link

dataValues returns relationship information while getDataValues does not #94

Open Ansis100 opened 7 months ago

Ansis100 commented 7 months ago

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.