Converting Couchbase Lite Document to Object

Hi,

I have around a thousand documents stored in my bucket each with over 100 properties, I can get them using the Document.UserProperties but was wondering if there was a quick way to convert these to an object rather than using reflections and mapping each property.

Thanks,
Shahid

Hi @shahidj7734,

Would the dynamic type in C# do what you want? I use it all the time for demos (because I’m lazy like that).

I don’t think so, my end goal is to have a list of objects from the bucket and use that to average, sum, etc its various properties. I think the easiest way would be to deserialize it somehow if I could get the raw json from the document

@shahidj7734,

If you just want the raw JSON, you can use bucket.Get<string>("yourkey");

How are you calling that? I only see the Bucket, Manager, and Document class from the CouchBase.Lite nuget package

Hi,

Can you tell us the language you’re using, and the version of couchbase Lite ?

For what I know, I’m using CBL 2.0 last version db21, and there is no direct way as simple as the .netClient version for inserting directly in the Bucket.
The developper team will add that in a futur version.

You can use the methode SetDictionary, It makes a good work.

Whatever the solution you will choose, keep in mind they will add the methode in a future version, It will be good to be able to switch easely.

The developper team knows that we are waiting for this !

Reagards,

Steeve

@shahidj7734,

My apologies, I assumed you meant Server (this is the Server forum, but I see “Lite” in the title now)