Deserialize Javascript Date on get


#1

I’m saving a document which has javascript Date values, and wish to get it back the same way.

Found a way to achieve this using plain Javascript, by using the second parameter of JSON.parse. JSON.parse(stringDocument, converterFunction).

To achieve this, I need the document as string, but the “bucket.get” returns it already deserialized.
Is there any way to disable the deserialization, without doing stringify + parse?


#2

Hey @adrian.c.petrescu,

It looks like what you are looking for is our transcoder methods. These allow you to intercept the data received from Couchbase and perform your own kind of encoding/decoding on them.
http://docs.couchbase.com/sdk-api/couchbase-node-client-2.1.4/Bucket.html#setTranscoder

Cheers, Brett


#3

Thanks Brett.

What is the default Encoder, in case I only wish to override the Decoder?

Cheers, Adrian