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 <hila...@drgeo.eu> 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 via email to