Re: How to define an array property

33 views
Skip to first unread message

Brian Underwood

unread,
Oct 2, 2014, 6:42:38 AM10/2/14
to neo...@googlegroups.com
Would the serialize method work for you?

https://github.com/neo4jrb/neo4j/wiki/Neo4j%3A%3AActiveNode#property-serialization

Brian
;p

On Thu, Oct 2, 2014 at 12:27 PM, Paolo Di Pietro
<paolodi...@gmail.com> wrote:
> Hi all,
>
> I'm using the 3.0 version
>
> I would like to model the following, but I'm not sure if it is possible:
>
> property :default_language, type: String
> property :allowed_languages, type: String []
>
> Well, I could model as an has_n relationship, but as it only contains
> ordered simple type objects I would like to manage as a plan property.
>
> Any suggestion?
>
> TIA
>
> Paolo
>
> --
> You received this message because you are subscribed to the Google Groups
> "neo4jrb" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to neo4jrb+u...@googlegroups.com.
> To post to this group, send email to neo...@googlegroups.com.
> Visit this group at http://groups.google.com/group/neo4jrb.
> For more options, visit https://groups.google.com/d/optout.

Andreas Ronge

unread,
Oct 2, 2014, 6:56:14 AM10/2/14
to neo...@googlegroups.com
I don't think property serialization is a good idea since neo4j support arrays as properties.
I think it should work by just not declaring a type: `property :allowed_languages`
I can't remember but I think it is active_attr that handles the type parameter for the property and active_attr probably don't support arrays.

Brian Underwood

unread,
Oct 2, 2014, 7:10:31 AM10/2/14
to neo...@googlegroups.com
Ah, yeah, I had forgotten that neo4j supported arrays natively ;)

I just tried it and not specifying a type does work. If you want to
have a mixed data type array, then you would need something like
serialize because neo4j doesn't support that.

Brian
;p
Reply all
Reply to author
Forward
0 new messages