Voyage and Association

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Voyage and Association

HilaireFernandes
Hi,

I am having trouble to persist in a Voyage repository Association formed
with a key being a non string object (let's say a Month) and value a non
basic object, instance of a model object.

So far, I have an error bsonTypeCode not understood on my value object.
I could implement bsonTypeCode, but I suspect I will have trouble too
with the key, as I see from Voyage code it is persisted as a String.

An idea how to overcome this (without modifying my model)?

Fuel was persisting it fine.

Thanks

Hilaire

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: Voyage and Association

EstebanLM
Hi Hilaire,

the thing is mongo is JSON based and in JSON dictionaries are key-string, value-anything so we cannot persist them “as is”.
To do that I use a trick which is convert them to collections before persisting, using a helper class that comes with Voyage-Mongo, VOMongoKeyPair.

For example, you could describe your dictionary attribute as this:

mongoValue
        <voyageDescription>
       
        ^VOToManyDescription new
                attributeName: 'value';
                convertNullTo: [ Dictionary new ];
                accessor: (MAPluggableAccessor
                        read: [ :anObject |
                                anObject value associations
                                        collect: [ :each | VOMongoKeyPair fromAssociation: each ] ]
                        write: [ :anObject :value | (value collect: #asAssociation) asDictionary ]);
                yourself

hope this helps,

cheers!
Esteban

> On 1 Mar 2017, at 19:11, Hilaire <[hidden email]> wrote:
>
> Hi,
>
> I am having trouble to persist in a Voyage repository Association formed
> with a key being a non string object (let's say a Month) and value a non
> basic object, instance of a model object.
>
> So far, I have an error bsonTypeCode not understood on my value object.
> I could implement bsonTypeCode, but I suspect I will have trouble too
> with the key, as I see from Voyage code it is persisted as a String.
>
> An idea how to overcome this (without modifying my model)?
>
> Fuel was persisting it fine.
>
> Thanks
>
> Hilaire
>
> --
> Dr. Geo
> http://drgeo.eu
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Voyage and Association

HilaireFernandes
It will, thanks

Le 01/03/2017 à 20:42, Esteban Lorenzano a écrit :
> hope this helps,

--
Dr. Geo
http://drgeo.eu