Replies: 4 comments 1 reply
-
Actually, the trick is not worked 😂 |
Beta Was this translation helpful? Give feedback.
-
I just realized that I debugged in wrong place. I will update the status of this discussion later. Currently the function
|
Beta Was this translation helpful? Give feedback.
-
after debugging, I found out that it was my mistake when using the export function grpcTimestampToDate(data: GrpcTimestamp): Date {
const timestamp = new Timestamp();
const { nanos, seconds } = data;
timestamp.setNanos(nanos);
timestamp.setSeconds(seconds.low);
return timestamp.toDate();
}
createMap(
mapper,
GrpcVM,
VM,
grpcTimestampToDateConverter,
); it must be createMap(
mapper,
GrpcVM,
VM,
grpcTimestampToDateConverter(),
); I have two functions like that, one function I used correctly, but this one not 😂 |
Beta Was this translation helpful? Give feedback.
-
Hey @zgid123, thanks for the discussion and sorry for the late reply. I halted my OSS work while I was on vacation. I agree that Did you solve your problem? |
Beta Was this translation helpful? Give feedback.
-
Hi, I checked the
typeConverter
example, we haveTimestampString
is extended fromDate
class, so when the mapper runs, those code lines will be skipped because theTimestampString
isisDateConstructor
. It won't run the functiongetMapping
to get the correctmapping
frommapper
.I am working with
Timestamp
of google protobuf (google-protobuf/google/protobuf/timestamp_pb
), to pass it to thegRPC
, we need to doTimestamp.fromDate(new Date()).toObject()
, the object's structure is{ seconds: number; nanos: number; }
.I don't wanna config mapping for this structure and wanna pass to
typeConverter
like thisBut the
hasSameIdentifier
above will be true, and the library will throw error. Don't you think we should have a function or an option to make thehasSameIdentifier
to be false with the classGrpcTimestamp
? Or do we have a workaround to make it? Because I wanna reuse the logic to convert allGrpcTimestamp
toDate
.I researched the code and couldn't find a way. Because maybe I will have some classes to work like that in the future and wanna do the
typeConverter
like that. Currently, I extend theGrpcTimestamp
fromDate
to do the trick.If we already have a solution, please help.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions