neo4j-php-ogm icon indicating copy to clipboard operation
neo4j-php-ogm copied to clipboard

Dealing with schema-less properties

Open davidhiendl opened this issue 7 years ago • 4 comments

The documentation contains no mention on how to deal with schema-less properties (eg. not mapped to a class field). It would be helpful to be able to access un-mapped properties by key with generic getters & setters.

Currently I have no idea how to realize this even after browsing the source code. The only way I could think of doing this efficiently is creating a custom / modified proxy-factory implementation.

Or did I miss something?

davidhiendl avatar Oct 13 '17 11:10 davidhiendl

What is the purpose of having a need to access properties from the db if they are not mapped as class fields ?

ikwattro avatar Oct 13 '17 14:10 ikwattro

Sometimes you might not know all properties ahead of time or they might be dynamic, yes you can represent that with relations and more often that not that is the better approach. But sometimes it is not or will yield many 1-value nodes (which is undesirable since they are not their own "thing").

My current use case is where this might be an issue is processing user-data. The properties are not all known ahead of time (nor should they be). I could have 1 node per entity with property access or 1+N (property count) nodes which would increase the amount of nodes (for my small sample data set) from 100,000 to 2,000,000.

davidhiendl avatar Oct 14 '17 07:10 davidhiendl

I see, we would need to add a specific annotation for that for first being able to retrieve them. Am not sure yet that changes to those properties should be mapped against the db during the flush events.

ikwattro avatar Oct 15 '17 02:10 ikwattro

I think it would be reasonable to mirror the Java OGM's behavior which maps any properties starting with a "prefix_" to a map. I believe it also does respect changes to this map.

If you point me in the right direction where this should be implemented I'd willing to work on this as I'm moving forward with my project and decided to use the PHP OGM.

davidhiendl avatar Jan 24 '18 19:01 davidhiendl